Vim: Combining autocmd?

左心房为你撑大大i 提交于 2019-12-03 16:09:42

I have a correction to @Eevee answer: to make autocommand work for one buffer only, you should use

augroup TexAutoWrite
    autocmd FileType tex :autocmd! TexAutoWrite InsertLeave <buffer> :update
augroup END

, see `:h autocmd-buflocal.

InsertLeave still needs a parameter.

This works for me:

autocmd FileType tex :autocmd InsertLeave * :w

Note that this behavior will remain if you later edit a non-tex file in the same buffer. I'm not sure if there's a simple way to remove it when editing anything but a certain type of file.

You can use the pattern option of the autocmnd.

autocmd InsertLeave *.tex w
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!