I want my app to update automatically when I save my files. So I use inotify (ubuntu) to create watchers that detect the events.
The issue is vim overwrites the file instead of updating it. So my watcher is lost after the first update.
I wonder, is there a way to setup vim so it doesn't use swap files and updates directly the file ?
(I tried :set noswapfile
and the -n
option, that removes the swap file without changing the behaviour)
You can do this:
:set backupcopy=yes
With Vim, you can control this via the 'backupcopy'
setting; however, I once took an alternative route and monitored the directories, not the files themselves:
inotifywait --quiet --monitor --event modify --format '%w%f' "$dir"
This required some more processing in my script (checking whether the modified file matches my list), but also enabled me to capture newly created files, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With