Is it possible to have vim prevent the saving of a php file that has a parse error?

I use vim and would like it to prevent me from saving php files that has parse errors. If I would like to use for instance "php -l " to achieve this, how would the autocmd in .vimrc look like?

I know I can hook into BufWritePre with something like

autocmd FileType php autocmd BufWritePre * !php -l %

but I want it to abort the "write" if the php command fails.

9
задан Christer 19 May 2011 в 08:34
поделиться