Skip to content
Advertisement

Validate PHP syntax in VIM

I would like to know how if it’s possible to validate if a PHP file is valid in VIM without closing VIM every time?

Thank you

Advertisement

Answer

You can execute shell commands in vim. This is the same as calling php -l filename.php from the shell:

:!php -l %

I have this mapped into my ~/.vim/after/ftplugin/php.vim file so that I only have to press F5:

map <F5> :!php -l %<CR>
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement