m (Reverted edits by 14.1.193.88 (talk | block) to last version by JohnBot) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{Deprecated|The official Vim distribution—since at least Vim 6.4—comes with a compiler script so you can type < |
+ | {{Deprecated|The official Vim distribution—since at least Vim 6.4—comes with a compiler script so you can type <code>:compiler perl</code>}} |
{{TipImported |
{{TipImported |
||
|id=473 |
|id=473 |
||
|previous=472 |
|previous=472 |
||
|next=474 |
|next=474 |
||
− | |created= |
+ | |created=2003 |
|complexity=basic |
|complexity=basic |
||
|author=Chris Forkin |
|author=Chris Forkin |
||
|version=5.7 |
|version=5.7 |
||
|rating=18/9 |
|rating=18/9 |
||
+ | |category1=Compiler |
||
+ | |category2=Perl |
||
}} |
}} |
||
− | At one stage I was writing a lot of perl scripts/modules with Vim and found it useful to be able to run the perl syntax-checker (perl -c) from within Vim via the < |
+ | At one stage I was writing a lot of perl scripts/modules with Vim and found it useful to be able to run the perl syntax-checker (perl -c) from within Vim via the <code>:make</code> command. To be able to do this you'll need to add the following Module (VimCompile.pm) to your @INC. |
<pre> |
<pre> |
||
Line 32: | Line 34: | ||
} |
} |
||
− | $SIG{'__DIE__'}=\& |
+ | $SIG{'__DIE__'}=\&_die; |
− | $SIG{'__WARN__'}=\& |
+ | $SIG{'__WARN__'}=\&_warn; |
# return OK |
# return OK |
||
Line 63: | Line 65: | ||
---- |
---- |
||
− | [[Category:Perl]] |
||
:!perl -Wc % |
:!perl -Wc % |
Revision as of 15:42, 13 April 2015
This tip is deprecated for the following reasons:
The official Vim distribution—since at least Vim 6.4—comes with a compiler script so you can type :compiler perl
created 2003 · complexity basic · author Chris Forkin · version 5.7
At one stage I was writing a lot of perl scripts/modules with Vim and found it useful to be able to run the perl syntax-checker (perl -c) from within Vim via the :make
command. To be able to do this you'll need to add the following Module (VimCompile.pm) to your @INC.
#!/usr/bin/perl -w #$Id: VimCompile.pm,v 1.2 2002/02/16 01:07:03 forkin Exp $ # reformat "perl -c" syntax-check error-/warning-messages for Vim package VimCompile; use strict; sub _die { my ($msg)=@_; $msg=~s/^((.* at )((.*) line )([0-9]+)(\.|, near .*))$/$4:$5: $1/mg; die qq/$msg/; } sub _warn { my ($msg)=@_; $msg=~s/^((.* at )((.*) line )([0-9]+)(\.|, near .*))$/$4:$5: $1/mg; warn qq/$msg/; } $SIG{'__DIE__'}=\&_die; $SIG{'__WARN__'}=\&_warn; # return OK 1;
This Module will reformat the warnings/errors so that Vim can parse them (to allow you to jump to the location/source-code of the error). You will also need to deposit the following (perl.vim) in your ~/.vim/runtime/compiler directory.
" Vim compiler file " Compiler: perl (output of "die" massaged) " Maintainer: Chris Forkin, chris@forkin.com if exists("current_compiler") finish endif let current_compiler = "perl" " A workable errorformat for "perl -c" setlocal errorformat=%f:%l:\ %m " default make setlocal makeprg=perl\ -MVimCompile\ -c\ %
Comments
or have a look at $VIMRUNTIME/tools/efm_perl.pl to use quickfix mode with perl scripts.
- !perl -Wc %
Actually disregard my perl -Wc comment I realise yours does more then simple compiler checks.