I keep a log file, and want it to be written to disk without having to manually save it after every edit.
I've used the
:au! CursorHoldI,CursorHold <buffer> silent! :update command that I found somewhere, and that works well, and is efficient: with
'updatetime' of 4 seconds by default, it will write the file to disk (only if changed, hence
:write) after the cursor has been in the same place for 4 seconds, in both insert and normal modes. (While the buffer has focus within Vim. Whether or not Vim has focus, which is a subtle point. That is, if Vim loses focus, the file is still saved after 4 seconds.)
The only problem is that if I have another file open with
:split, and click or Ctrl+W,k there, then the original file is not saved after
'updatetime' ms. How can this be corrected?