7

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?

math
  • 2,633
  • 8
  • 31
  • 43

1 Answers1

6

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

akira
  • 61,009
  • 17
  • 135
  • 165
  • Yeah this also complies with my observation that inotifywait printed the same inode number that has changed.. – math May 04 '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 04 '12 at 14:31