From 719d14e04795588c4a91306880ee1bc726032516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20D=C3=A9saulniers?= Date: Thu, 19 Jan 2017 22:17:52 -0500 Subject: [PATCH] option to disable autocmd on file write --- plugin/AutoSave.vim | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugin/AutoSave.vim b/plugin/AutoSave.vim index f8ea08c..cbd97d5 100644 --- a/plugin/AutoSave.vim +++ b/plugin/AutoSave.vim @@ -21,6 +21,10 @@ if !exists("g:auto_save_silent") let g:auto_save_silent = 0 endif +if !exists("g:auto_save_noautocmd") + let g:auto_save_noautocmd = 0 +endif + if !exists("g:auto_save_write_all_buffers") let g:auto_save_write_all_buffers = 0 endif @@ -88,11 +92,17 @@ function! AutoSave() endfunction function! DoSave() + let l:write_cmd = "" + if g:auto_save_noautocmd >= 1 + let l:write_cmd .= "noautocmd" . " " + endif + + let l:write_cmd .= "silent! w" if g:auto_save_write_all_buffers >= 1 - silent! wa - else - silent! w + let l:write_cmd .= "a" endif + + execute l:write_cmd endfunction function! AutoSaveToggle() @@ -107,3 +117,5 @@ endfunction let &cpo = s:save_cpo unlet s:save_cpo + +" vim:sw=2:ts=2: