Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get basic PHP error underlining in VIM?

Tags:

php

vim

ide

I really like VIM but one thing I cannot do without is simple error underlying like in netbeans and Visual Studio. I often make silly mistakes like

    if checkit($url) 
    {
    }

instead of

if (checkit($url))
{
}

The little squiggly red underline is a lifesaver when it comes to stuff like that. Is there a plugin for VIM that will save me from php silly mistake hell? Thanks.

like image 252
stormist Avatar asked Feb 28 '23 18:02

stormist


2 Answers

Use Syntastic

To make it work efficiently you can add this one small customization to your .vimrc:

function! s:SaveAll()
    w | :Error
endfunction
command! -bar -narg=0 W call s:SaveAll()

now using :W for saving your file will also show a location list with any errors.

like image 192
lukaszkorecki Avatar answered Mar 08 '23 10:03

lukaszkorecki


Have a look at the CheckSyntax plugin for vim, which has support for the equivalent of the 'php -l' and 'php -f' checks.

Vim doesn't have support for the squiggly underline we're all so used to but you might be able to get the "red marker in a column" effect used in Eclipse with help from this blog post.

like image 45
Mark McDonald Avatar answered Mar 08 '23 11:03

Mark McDonald