I started to write this .vimrc file because I wanted my programs to use 4-space (actual spaces!) identation.
That was a simple need, but, after a quick research, I found many features that made Perl programming more enjoyable in Vim.
Without more delay, here's my .vimrc file:
" use visual bell instead of beeping set vb " incremental search set incsearch " syntax highlighting set bg=light syntax on " autoindent autocmd FileType perl set autoindent|set smartindent " 4 space tabs autocmd FileType perl set tabstop=4|set shiftwidth=4|set expandtab|set + softtabstop=4 " show matching brackets autocmd FileType perl set showmatch " show line numbers autocmd FileType perl set number " check perl code with :make autocmd FileType perl set makeprg=perl\ -c\ %\ $* autocmd FileType perl set errorformat=%f:%l:%m autocmd FileType perl set autowrite " dont use Q for Ex mode map Q :q " make tab in v mode ident code vmap <tab> >gv vmap <s-tab> <gv " make tab in normal mode ident code nmap <tab> I<tab><esc> nmap <s-tab> ^i<bs><esc> " paste mode - this will avoid unexpected effects when you " cut or copy some text from one window and paste it in Vim. set pastetoggle=<F11> " comment/uncomment blocks of code (in vmode) vmap _c :s/^/#/gi<Enter> vmap _C :s/^#//gi<Enter> " my perl includes pod let perl_include_pod = 1 " syntax color complex things like @{${"foo"}} let perl_extended_vars = 1 " Tidy selected lines (or entire file) with _t: nnoremap <silent> _t :%!perltidy -q<Enter> vnoremap <silent> _t :!perltidy -q<Enter> " Deparse obfuscated code nnoremap <silent> _d :.!perl -MO=Deparse 2>/dev/null<cr> vnoremap <silent> _d :!perl -MO=Deparse 2>/dev/null<cr>
Most of the features are self-evident when you open your next perl script. Other features deserve some comments:
- Use ":make" to check your code: it will call "perl -c" to verify your code and, if there are any erros, the cursor will be positioned in the offending line.
- Get rid of the Ex mode: I often entered in Ex mode when I wanted to type ":q"...
- Indent code with tabs: Use "v" to select a region, or indent line by line in normal mode. (Use shift-tab to unindent.)
- Press F11 to toggle the "paste mode", disabling autoindent so that any text you paste won't loose its original layout.
- UPDATE: added some hints from the comments.
I hope you'll find those tricks useful!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: .vimrc for perl programmers
by rnahi (Curate) on Mar 30, 2006 at 14:55 UTC | |
by runrig (Abbot) on Mar 30, 2006 at 17:00 UTC | |
Re: .vimrc for perl programmers
by jasonk (Parson) on Mar 30, 2006 at 14:19 UTC | |
Re: .vimrc for perl programmers
by philcrow (Priest) on Mar 30, 2006 at 14:25 UTC | |
by tinita (Parson) on Mar 30, 2006 at 15:27 UTC | |
Re: .vimrc for perl programmers
by tinita (Parson) on Mar 30, 2006 at 14:24 UTC | |
by demerphq (Chancellor) on Mar 30, 2006 at 17:58 UTC | |
by mreece (Friar) on Nov 01, 2006 at 17:11 UTC | |
by demerphq (Chancellor) on Nov 01, 2006 at 17:50 UTC | |
by cees (Curate) on Mar 30, 2006 at 21:53 UTC | |
Re: .vimrc for perl programmers
by vagnerr (Prior) on Mar 30, 2006 at 15:16 UTC | |
Re: .vimrc for perl programmers
by jhourcle (Prior) on Mar 30, 2006 at 15:02 UTC | |
Re: .vimrc for perl programmers
by dragonchild (Archbishop) on Mar 30, 2006 at 16:20 UTC | |
by cees (Curate) on Mar 30, 2006 at 22:07 UTC | |
by unobe (Scribe) on Apr 04, 2006 at 08:56 UTC | |
by Anonymous Monk on Mar 04, 2013 at 22:31 UTC | |
Re: .vimrc for perl programmers
by cees (Curate) on Mar 30, 2006 at 21:50 UTC | |
Re: .vimrc for perl programmers
by Codon (Friar) on Mar 31, 2006 at 08:40 UTC | |
Re: .vimrc for perl programmers
by planetscape (Chancellor) on Mar 31, 2006 at 08:39 UTC | |
Re: .vimrc for perl programmers
by cees (Curate) on Mar 30, 2006 at 22:30 UTC | |
Re: .vimrc for perl programmers
by idle (Friar) on Mar 31, 2006 at 13:45 UTC | |
Re: .vimrc for perl programmers
by bowei_99 (Friar) on Apr 02, 2006 at 03:23 UTC | |
Re: .vimrc for perl programmers
by Ovid (Cardinal) on Dec 19, 2007 at 15:09 UTC | |
Deobfuscate code from vim
by nferraz (Monk) on Aug 28, 2008 at 09:53 UTC | |
Re: .vimrc for perl programmers
by Codon (Friar) on Dec 19, 2007 at 13:54 UTC | |
by john_oshea (Priest) on Dec 19, 2007 at 14:55 UTC | |
Re: .vimrc for perl programmers
by shmem (Chancellor) on Nov 02, 2006 at 12:44 UTC | |
Re: .vimrc for perl programmers
by diogoleal (Initiate) on Apr 24, 2011 at 17:11 UTC | |
Re: .vimrc for perl programmers
by vinayendra (Novice) on Oct 05, 2017 at 23:04 UTC |
Back to
Meditations