I've read that most editors will replace the file when you actually want to save changes to that file How to execute a command whenever a file changes?. So how does VIM behave?


it might depend on various settings related to 'backup', everything that has to keep a copy of the file as it was before the write happened. one of settings that controls that is: 'backupcopy':

When writing a file and a backup is made, this option tells how it's done. This is a comma separated list of words.

The main values are:

"yes"    make a copy of the file and overwrite the original one
"no"     rename the file and write a new one
"auto"   one of the previous, what works best

so, depending on your vimrc (backup set and backupcopy to no), vim might rename a file. when

  • Yeah this also complies with my observation that inotifywait printed the same inode number that has changed.. – math May 4 '12 at 11:46
  • 1
    comment on @math's comment: i changed the answer quite a bit after his comment. the former version stated that the test i did wrote into the same inode / file. but since my vimrc runs without backup ... not a valid test :) – akira May 4 '12 at 14:31

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.