1

When a file is changed (e.g. by checking out another git branch), and i reload it with :bufdo e, I get the message

W11: Warning: File "foo.bar" has changed since editing started
See ":help W11" for more info.
[O]K, (L)oad File:

What's the difference between hitting O and L?

0
1

If you read the specified help section (:h W11) you'll get some details on what's going on. In short, the file from which you loaded the current buffer has changed. Specifically, its timestamp and content are different

Without some extra steps (below), you can only keep one version. To keep what you're currently looking at press Enter. L will load whatever is in the file on disk losing any changes you've made in the buffer since your last write.

You could hit Enter, then :w to a different filename, then do :e again. That way you'll preserve both versions.

Note that the triggering and/or display of this warning is particular to certain configurations. For example, with 'hidden' set you can get the warning if have unsaved changes in the buffer and then you move out of the buffer and back in. Without 'hidden' you won't see it because you'll get a warning about your unsaved changes and won't be able to leave the buffer without saving. Another example is 'autoread': if it's enabled you will not encounter the conditions that trigger the warning. And one more example is 'buftype' which must be empty for the warning to appear. (It is empty for regular buffers but things like popups, terminals, quickfix windows, etc. set it to something.)

8
  • O doesn't seem to keep the currently loaded version (before change). It seems to also reload the file. Try this: open some files in vim, add/change a line in one of the files from some other program externally, then do :bufdo e in vim, and hit O when prompted about the changed file. You should see the modified file is now loaded. – Zaid Gharaybeh Feb 2 at 21:36
  • For some reason I don't get the warning without bufdo e. E.g. if i change the file externally, and just do :e, it reloads the file without the warning. That's why I'm having you go through hoops lol – Zaid Gharaybeh Feb 2 at 21:42
  • I assume you have hidden set. With bufdo you leave the buffer hidden temporarily. I'd guess that has something to do with it. As to why you're not getting the warning without bufdo that's currently a mystery. I'll see what I see myself. – B Layer Feb 2 at 21:44
  • Yes, I do have set hidden in my vimrc. So do you get the warning on your end with just one file using :e? – Zaid Gharaybeh Feb 2 at 21:46
  • 1
    Try using the conditions I describe. Get a baseline. – B Layer Feb 2 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.