Ok, it's not about compiling exactly, but recently I discovered the :compiler
command in Vim. The help is included in the quickfix documentation, and as fas as I understood I could run:
:compiler perl
To select the perl interpreter. Then, the help says:
The Perl compiler plugin doesn't actually compile, but invokes Perl's internal syntax checking feature and parses the output for possible errors so you can correct them in quick-fix mode.
But as it's unclear what should I to actually run the program. May I run :make
, even without a make file? That makes sense to me, since:
echo &makeprg
Returns perl -Wc %
. However…
Doing that on a bogus test program, only returns the standard errors formatting output, no quickfix window is opened. What am I missing here?
Just open the quickfix window with
:copen
Navigate errors with
:crew
:cnext
:cprev
Note that a common trap with quickfixing using a non-project make (i.e. where the makeprg variable usually includes the name of the current buffer (expansion of %
)), is that when the focus is on the quickfix window, issueing :make
again will fail, because the quickfix buffer has no filename associated with it. Perhaps this could be fixed by supplying an artificial name for the quickfix window in e.g. the Perl compiler mode for vim?
Using the following code, and F6 can run perl script and shown at quickfix.
func! checkPerlSyntax()
let map = &makeprg
let ef = &errorformat
let exeFile = expand("%:t")
setlocal makeprg=perl
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
silent make %
copen
let &makeprg = mp
let &errorformat = ef
endfunc
nmap pl :!perl %<.pl<CR>
map <F6> :call checkPerlSyntax()<CR>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With