Actually I want to autosave my current file, :w
command writes the file so I thought that when I will repeat this command at regular interval (say each 30secs.) I will achieve what I want. But how can I do so?
Vimscript itself is single-threaded; you cannot regularly execute a command per se. The closest to a periodic trigger are autocmds, especially the CursorHold
event, which fires after no key has been pressed for 'updatetime'
, typically 4 seconds.
Another interesting event for auto-saving is FocusLost
, but that one may not be triggered in the terminal, just in GVIM.
With it, something like this can be defined:
autocmd CursorHold,CursorHoldI <buffer> silent! write
Take a look into :help autosave
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