Debugging PHP Using VIM Using Quickfix

I followed some tutorials to debug and use php code through VIM.

Here is my piece of PHP code to test

<?php echo "test" echo "test2";?> 

The following code worked for me:

 :autocmd FileType php noremap <CL> :!$HOME/bin/php -l %<CR> 

He tells me there is a syntax error. The problem is that I want to use the quick fix console. So here is the code:

 set makeprg="php -l %" nmap <F9>:make<ENTER>:copen<ENTER><CTRL>L 

F9 opens a quick fix window, but does not detect a syntax error. (I save my php document to: w)

Thank you for your time!

+4
source share
1 answer

The problem I see is using " w / :set . I suggest the following:

 :set makeprg=php\ -ln\ % :set errorformat=%m\ in\ %f\ on\ line\ %l nnmap <f9> :sil! make<cr>:cwindow<cr> 

To make it more friendly to other types of files, I suggest you add the following to your ~ / .vim / after / ftplugin / php.vim and make sure that you use :setlocal and your mappings have a <buffer> attribute for example:

 :setlocal makeprg=php\ -ln\ % :setlocal errorformat=%m\ in\ %f\ on\ line\ %l nnmap <buffer> <f9> :sil! make<cr>:cwindow<cr> 
+3
source

Source: https://habr.com/ru/post/1368984/


All Articles