Vim Tips Wiki

Compiler for perl

1,624pages on
this wiki
Add New Page
Talk0 Share

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

Tip 473 Printable Monobook Previous Next

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 ( to your @INC.

#!/usr/bin/perl -w
#$Id:,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/;

# return OK


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,

if exists("current_compiler")

let current_compiler = "perl"
" A workable errorformat for "perl -c"
setlocal errorformat=%f:%l:\ %m
" default make
setlocal makeprg=perl\ -MVimCompile\ -c\ %


:help errorformat-Perl

or have a look at $VIMRUNTIME/tools/ to use quickfix mode with perl scripts.

!perl -Wc %

Actually disregard my perl -Wc comment I realise yours does more then simple compiler checks.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki