I\'d like vim to automatically write my file as often as possible. The ideal would be every keystroke.
I need to save regularly so that my background build process wi
One hack is to use your status line:
function! WriteFile()
if &buftype == ""
write
endif
return '%f %h%w%m%r%=%-14(%l,%c%V%) %(%P%)'
endfunction
setlocal statusline=%!WriteFile()
set laststatus=2
As long as the status line is visible, it's updated after each change to the file.
When updated, the WriteFile()
function is called, which writes the file (and returns my approximation at the default status line). With laststatus=2
, the status line is shown even when only one window is open.
This will keep the current buffer saved after each change.