tags:

views:

149

answers:

1

I need to do the logical-and of two autocmd events in vim. Basically, the command has to run on an InsertLeave when the FileType is tex. It seems like this should work (in a .vimrc):

autocmd FileType tex :autocmd InsertLeave :w

But it doesn't. The nested option doesn't seem to help either, even though the manual indicates it should.

Its easy to do a logical-OR:

autocmd BufEnter,BufLeave ...

it mustn't be too hard to do a logical-AND.

+2  A: 

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.

Eevee
Indeed, works like a charm.
Paul Biggar