What are your suggestions for an ideal Vim configuration for Perl development?

There are a lot of threads pertaining to how to configure Vim/GVim for Perl development on PerlMonks.org. My purpose in posting this question is to try to create, as much as possible, an ideal configuration for Perl development using Vim/GVim. Please post your suggestions for .vimrc settings as well as useful plugins.

I will try to merge the recommendations into a set of .vimrc settings and to a list of recommended plugins, ftplugins and syntax files.

.vimrc settings

"Create a command :Tidy to invoke perltidy"
"By default it operates on the whole file, but you can give it a"
"range or visual range as well if you know what you're doing."
command -range=% -nargs=* Tidy <line1>,<line2>!
    \perltidy -your -preferred -default -options <args>

vmap <tab> >gv    "make tab in v mode indent code"
vmap <s-tab> <gv

nmap <tab> I<tab><esc> "make tab in normal mode indent code"
nmap <s-tab> ^i<bs><esc>

let perl_include_pod   = 1    "include pod.vim syntax file with perl.vim"
let perl_extended_vars = 1    "highlight complex expressions such as @{[$x, $y]}"
let perl_sync_dist     = 250  "use more context for highlighting"

set nocompatible "Use Vim defaults"
set backspace=2  "Allow backspacing over everything in insert mode"

set autoindent   "Always set auto-indenting on"
set expandtab    "Insert spaces instead of tabs in insert mode. Use spaces for indents"
set tabstop=4    "Number of spaces that a <Tab> in the file counts for"
set shiftwidth=4 "Number of spaces to use for each step of (auto)indent"

set showmatch    "When a bracket is inserted, briefly jump to the matching one"

syntax

  • vim-perl: Support for Perl 5 and Perl 6 in Vim

plugins

  • delimitMate provides auto-completion for quotes, parens, brackets, etc. in insert mode. It handles apostrophes more intelligently than closepairs.vim does.

  • perlhelp.vim: Interface to perldoc

  • taglist.vim: Source code browser

ftplugins

  • perldoc.vim: perldoc command from vim

CPAN modules

  • Vim::X

Debugging tools

I just found out about VimDebug. I have not yet been able to install it on Windows, but looks promising from the description.


From chromatic's blog (slightly adapted to be able to use the same mapping from all modes).

vmap ,pt :!perltidy<CR> 
nmap ,pt :%! perltidy<CR>

hit ,pt in normal mode to clean up the whole file, or in visual mode to clean up the selection. You could also add:

imap ,pt <ESC>:%! perltidy<CR>

But using commands from input mode is not recommended.


" Create a command :Tidy to invoke perltidy.
" By default it operates on the whole file, but you can give it a
" range or visual range as well if you know what you're doing.
command -range=% -nargs=* Tidy <line1>,<line2>!
    \perltidy -your -preferred -default -options <args>

Look also at perl-support.vim (a Perl IDE for Vim/gVim). Comes with suggestions for customizing Vim (.vimrc), gVim (.gvimrc), ctags, perltidy, and Devel:SmallProf beside many other things.


Perl Best Practices has an appendix on Editor Configurations. vim is the first editor listed.


Andy Lester and others maintain the official Perl, Perl 6 and Pod support files for Vim on Github: https://github.com/vim-perl/vim-perl