Wednesday, June 3, 2009

Checking Perl Syntax Within Vim

Sick of switching back and forth between your shell and Vim buffer fixing syntax errors and adding forgotten "use" statements? Running perl -c is a handy command to run on your Perl source files to check for syntax errors. Here's a little key mapping to add to your .vimrc file:
map ,pc <Esc>:! perl -c %<CR>
Now type ,pc (mnemonic: perl -c) in command mode to check the syntax of your Perl source file without having to switch windows. It is a little annoying to have to do it multiple times (if there are many errors) since Vim swaps between the file you're editing and the shell to show the output, but it's definitely a step above manually swapping windows :)

No comments:

Post a Comment