27 lines
455 B
VimL
27 lines
455 B
VimL
if exists('g:loaded_autosave')
|
|
finish
|
|
endif
|
|
let g:loaded_autosave = 1
|
|
|
|
let g:autosave = get(g:, 'autosave', 0)
|
|
|
|
fu! s:autosave_start()
|
|
aug autosave
|
|
au!
|
|
au TextChanged,CursorHold,InsertLeave * sil! update
|
|
aug END
|
|
echo 'autosave: on'
|
|
endf
|
|
|
|
fu! s:autosave_stop()
|
|
au! autosave
|
|
echo 'autosave: off'
|
|
endf
|
|
|
|
com! AirsaveOn call <SID>autosave_start()
|
|
com! AirsaveOff call <SID>autosave_stop()
|
|
|
|
if g:autosave
|
|
call <SID>autosave_start()
|
|
endif
|