4 ms·
What version of Vim? Because I've never experienced this problem in over a decade of use. Try it yourself: echo "test1" > test1 ln test1 test2 vi
by graywh 7y ago
What version of Vim? Because I've never experienced this problem in over a decade of use.
Try it yourself:
echo "test1" > test1
ln test1 test2
vim -c 's/1/2/' -c x test2
cat test1
Edit: Oh, you can configure Vim to break hardlinks
https://vim.fandom.com/wiki/Editing_a_hard_link_to_a_file https://vim.fandom.com/wiki/Editing_a_hard_link_to_a_file
- nemetroid 7y agoSorry, you're right. Sadly I cannot edit my comment since too long time has passed. I should of course tested with an added hard link. Vim does do the rename/unlink if there only is a single hard link to a file, which makes inotify behave different than expected, so my guess was that Vim would also be OK with breaking hard links. But it makes sense that it wouldn't, since hard links are a much more integral part of Unix. $ echo 1 > test1 $ inotifywait --quiet --monitor test1 & [1] 14321 $ vim -c 's/1/2/' -c x test1 $ cat test1 2 $ <no output from inotifywait> With multiple hard links, the inode is preserved (only difference is adding the call to ln): $ echo 1 > test1 $ ln test1 test2 $ inotifywait --quiet --monitor test1 & [1] 14361 $ vim -c 's/1/2/' -c x test1 $ cat test1 2 test1 OPEN test1 ACCESS test1 CLOSE_NOWRITE,CLOSE $