Hi,
In order to let vim auto-save files, I tried the follwing plugin:
https://github.com/907th/vim-auto-save
But, I found that sometimes it will not take effect and I don't know
what's the conflicts in my vim configurations.
So I want to find other methods to do this thing and I find the following one:
https://vi.stackexchange.com/questions/74/is-it-possible-to-make-vim-auto-save-files
And based on the above method given by dash-tom-bang, I revised into
the following code:
------------
if exists(':keeppatterns')
let s:keeppatterns = 'keeppatterns '
else
let s:keeppatterns = ''
endif
augroup AutoSaveGroup
" :help file-pattern has some info,
" but some of it is is buried in the PATTERNS section of usr_40.txt
"let s:autoPattern =
"*.{c,h,[ch]pp,[acjt]s,inl,cg,cgfx,fx,py,bat,cmd,jam,vim,yml,yaml,vsprops,erb,rb,html,htm},SCons*,*vimrc"
let s:autoPattern = "*"
autocmd!
execute "autocmd FocusLost" s:autoPattern "silent! wall"
execute "autocmd BufWritePre" s:autoPattern s:keeppatterns .
'call FixFormatting(expand("<afile>"))'
execute "autocmd FileChangedRO" s:autoPattern "silent !p4 edit %:p"
execute "autocmd FileChangedRO" s:autoPattern "write!"
autocmd FocusLost * silent! wall
augroup END
------------
I'm a newbie on vimscripts, and till now, it seems the above script
works smoothly.
I want to know is there any bugs/revisions/enhancenments on the above script?
Thanks in advance.
--
Hongsheng Zhao <
hongy...@gmail.com>
Institute of Semiconductors, Chinese Academy of Sciences
GnuPG DSA: 0xD108493