Vim & Inotify Issue
"IME has broken on terminal since I turn back to
sway
, had to use English on this article.
Things start as I found rathole has a weird implementation on their config hot-reload.
After I made a pr, developer point to another issue which explained this is a workaround specifically for vim,
which not fired modify
inotify event during modifying.
Let's make an experiment:
Create ./t, then touch file a
:
We have full control to this dir recursively. Then make a inotify watch continuedly:
This will watch the inotify event on file a in 10s.
We took some actions:
Ok, see what catches:
No modify event, but expect to have that:
This action fired modify event successfully as expected:
Take sight back to result of vim modified, here is a move_self
event, as this article mentioned,
vim default set backupcopy=no
, which caused behaviors that the original file is renamed to create a backup and a new file with the original name is created. This would not trigger the modify
event but the close_write
of parent directory and move_self
of itself.
Turn this option to yes means to copy the file to create a backup and then overwrite the original, thus inotify will trigger.
Under my test only vim has this problem, nano
and helix
both trigger the event normally.
Is there a more graceful way to watch the file change modified by vim ?