Eliminating "WARNING: The file has been changed since reading it"

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Eliminating "WARNING: The file has been changed since reading it"

Tim Chase
The subject more or less says it all, but using git and switching
branches will change the timestamps on my files even though the
underlying content doesn't seem to have changed.  I'd like to
tell Vim that, for certain filespecs (likely via an autocmd), I
don't want to see this message and that YES, I do want to always
overwrite the file.

Nothing that I found via a :helpgrep for that message suggested
an apparent way to disable this.

-tim



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Eliminating "WARNING: The file has been changed since reading it"

Dan Wierenga-2


On Wed, Oct 12, 2011 at 8:32 AM, Tim Chase <[hidden email]> wrote:
  I'd like to tell Vim that, for certain filespecs (likely via an autocmd), I don't want to see this message and that YES, I do want to always overwrite the file.


I think the autoread option is what you're after.

:help 'autoread'

 

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Eliminating "WARNING: The file has been changed since reading it"

Tim Chase
On 10/12/11 16:56, Dan Wierenga wrote:

> On Wed, Oct 12, 2011 at 8:32 AM, Tim
> Chase<[hidden email]>  wrote:
>
>> I'd like to tell Vim that, for certain filespecs (likely via
>> an autocmd), I don't want to see this message and that YES,
>> I do want to always overwrite the file.
>
> I think the autoread option is what you're after.
>
> :help 'autoread'

I tried tinkering with this setting but didn't have any success
with your suggestion:

   bash$ vim existing.txt
   :set autoread
   :$put='a last line'

(over in a second parallel terminal window, issue "touch
existing.txt")

   :w
   (gives the WARNING in the Subject, same with ":w!").

Same goes for trying to set 'noautoread' instead of 'autoread'.

-tim




--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Eliminating "WARNING: The file has been changed since reading it"

Christian Brabandt
On Thu, October 13, 2011 1:39 am, Tim Chase wrote:

> On 10/12/11 16:56, Dan Wierenga wrote:
>> On Wed, Oct 12, 2011 at 8:32 AM, Tim
>> Chase<[hidden email]>  wrote:
>>
>>> I'd like to tell Vim that, for certain filespecs (likely via
>>> an autocmd), I don't want to see this message and that YES,
>>> I do want to always overwrite the file.
>>
>> I think the autoread option is what you're after.
>>
>> :help 'autoread'
>
> I tried tinkering with this setting but didn't have any success
> with your suggestion:
>
>    bash$ vim existing.txt
>    :set autoread
>    :$put='a last line'
>
> (over in a second parallel terminal window, issue "touch
> existing.txt")
>
>    :w
>    (gives the WARNING in the Subject, same with ":w!").
>
> Same goes for trying to set 'noautoread' instead of 'autoread'.

Try setting 'buftype' to a non-empty value, maybe acwrite.
That shouldn't trigger that warning, but might have other unintended
side effects (and the help strongly advises, not to mess with that
option.)

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Eliminating "WARNING: The file has been changed since reading it"

Lech Lorens
In reply to this post by Tim Chase
On Oct 12, 5:32 pm, Tim Chase <[hidden email]> wrote:

> The subject more or less says it all, but using git and switching
> branches will change the timestamps on my files even though the
> underlying content doesn't seem to have changed.  I'd like to
> tell Vim that, for certain filespecs (likely via an autocmd), I
> don't want to see this message and that YES, I do want to always
> overwrite the file.
>
> Nothing that I found via a :helpgrep for that message suggested
> an apparent way to disable this.
>
> -tim

Yes, Vim can do it ;-)
Have a look at FileChangedShell autocommand. Here's part of my ~/.vim/
after/ftplugin/sh.vim that does what you need:

function! ProcessFileChangedShell()
        if v:fcs_reason == 'mode' || v:fcs_reason == 'time'
                let v:fcs_choice = ''
        else
                let v:fcs_choice = 'ask'
        endif
endfunction

autocmd FileChangedShell <buffer> call ProcessFileChangedShell()

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php