diff --git a/vim/plugin/autosave.vim b/vim/plugin/autosave.vim new file mode 100644 index 0000000..7e3adf7 --- /dev/null +++ b/vim/plugin/autosave.vim @@ -0,0 +1,19 @@ +" Extend autosavefeature :) + +function! TryAutosave() + if &autowriteall + if &mod + silent write + end + redraw + end +endfunction + +augroup autosave +autocmd! + autocmd BufLeave * call TryAutosave() + autocmd CursorHold * call TryAutosave() + autocmd InsertLeave * call TryAutosave() + autocmd TextChanged * call TryAutosave() + autocmd FocusLost * call TryAutosave() +augroup END diff --git a/vim/plugin/shame.vim b/vim/plugin/shame.vim index f99c8df..48000ce 100644 --- a/vim/plugin/shame.vim +++ b/vim/plugin/shame.vim @@ -688,36 +688,6 @@ function! s:toggleWUC() redraw endfunction -" Autosave when vim loses focus :) -function! TryAutosave(warn, mode) - if a:mode == 0 - if &autowriteall || &autowrite - silent wall - if a:warn - echo "Autosaving all buffers..." - end - end - elseif a:mode == 1 - if &autowriteall - if &mod - silent write - if a:warn - echo "Autosaving current buffer..." - end - end - end - end - - redraw -endfunction - -augroup autosave -autocmd! -autocmd FocusLost * call TryAutosave(0, 0) -autocmd BufLeave * call TryAutosave(0, 1) -autocmd CursorHold * call TryAutosave(0, 1) -augroup END - vnoremap g :call GrepOperator(visualmode()) nnoremap g :set operatorfunc=GrepOperatorg@ function! s:GrepOperator(type)