Let’s start simple. Vim website offers a handful of color schemes for all tastes and preferences. Finding and downloading these color schemes one by one can be a pain though. Luckily, world is not without kind people. Someone named Robert (MetaCosm) downloaded all color schemes and put them into a single archive file which he uploaded back to Vim’s web site. Let’s download it from http://www.vim.org/scripts/script.php?script_id=625.
Save colors.zip in your .vim/ directory and unzip it. Making sure that all the files in UNIX format is also a good idea.
[codemonkey@gucho .vim]$ ls colors.zip [codemonkey@gucho .vim]$ unzip colors.zip Archive: colors.zip creating: colors/ inflating: colors/adaryn.vim inflating: colors/adrian.vim inflating: colors/aqua.vim inflating: colors/astronaut.vim inflating: colors/asu1dark.vim inflating: colors/autumn.vim inflating: colors/biogoo.vim inflating: colors/blackdust.vim inflating: colors/BlackSea.vim inflating: colors/blue.vim inflating: colors/bluegreen.vim inflating: colors/bog.vim inflating: colors/borland.vim inflating: colors/breeze.vim inflating: colors/brookstream.vim inflating: colors/brown.vim inflating: colors/bw.vim inflating: colors/c.vim inflating: colors/camo.vim inflating: colors/candy.vim inflating: colors/caramel.vim inflating: colors/ChocolateLiquor.vim inflating: colors/coffee.vim inflating: colors/colorer.vim inflating: colors/colorscheme_template.vim inflating: colors/cool.vim inflating: colors/dante.vim inflating: colors/darkblue.vim inflating: colors/darkdot.vim inflating: colors/darkocean.vim inflating: colors/darkslategray.vim inflating: colors/dawn.vim inflating: colors/default.vim inflating: colors/denim.vim inflating: colors/desert.vim inflating: colors/elflord.vim inflating: colors/emacs.vim inflating: colors/evening.vim inflating: colors/fine_blue.vim inflating: colors/fnaqevan.vim inflating: colors/fog.vim inflating: colors/golden.vim inflating: colors/ibmedit.vim inflating: colors/ironman.vim inflating: colors/koehler.vim inflating: colors/lanzarotta.vim inflating: colors/lilac.vim inflating: colors/manxome.vim inflating: colors/midnight.vim inflating: colors/midnight2.vim inflating: colors/morning.vim inflating: colors/murphy.vim inflating: colors/navajo-night.vim inflating: colors/navajo.vim inflating: colors/night.vim inflating: colors/nightshimmer-theme.vim inflating: colors/nightwish.vim inflating: colors/northsky.vim inflating: colors/oceanblack.vim inflating: colors/oceandeep.vim inflating: colors/pablo.vim inflating: colors/PapayaWhip.vim inflating: colors/peachpuff.vim inflating: colors/potts.vim inflating: colors/print_bw.vim inflating: colors/rainbow_autumn.vim inflating: colors/rainbow_breeze.vim inflating: colors/rainbow_fine_blue.vim inflating: colors/rainbow_fruit.vim inflating: colors/rainbow_neon.vim inflating: colors/rainbow_night.vim inflating: colors/rainbow_sea.vim inflating: colors/redblack.vim inflating: colors/ron.vim inflating: colors/sand.vim inflating: colors/scite.vim inflating: colors/sean.vim inflating: colors/seashell.vim inflating: colors/shine.vim inflating: colors/taqua.vim inflating: colors/tomatosoup.vim inflating: colors/toothpik.vim inflating: colors/torte.vim inflating: colors/transparent.vim inflating: colors/whitedust.vim inflating: colors/wintersday.vim inflating: colors/xemacs.vim inflating: colors/xian.vim inflating: colors/zellner.vim inflating: colors/zenburn.vim [codemonkey@gucho .vim]$ dos2unix colors/* dos2unix: converting file colors/BlackSea.vim to UNIX format … dos2unix: converting file colors/ChocolateLiquor.vim to UNIX format … dos2unix: converting file colors/PapayaWhip.vim to UNIX format … dos2unix: converting file colors/adaryn.vim to UNIX format … dos2unix: converting file colors/adrian.vim to UNIX format … dos2unix: converting file colors/aqua.vim to UNIX format … dos2unix: converting file colors/astronaut.vim to UNIX format … dos2unix: converting file colors/asu1dark.vim to UNIX format … dos2unix: converting file colors/autumn.vim to UNIX format … dos2unix: converting file colors/biogoo.vim to UNIX format … dos2unix: converting file colors/blackdust.vim to UNIX format … dos2unix: converting file colors/blue.vim to UNIX format … dos2unix: converting file colors/bluegreen.vim to UNIX format … dos2unix: converting file colors/bog.vim to UNIX format … dos2unix: converting file colors/borland.vim to UNIX format … dos2unix: converting file colors/breeze.vim to UNIX format … dos2unix: converting file colors/brookstream.vim to UNIX format … dos2unix: converting file colors/brown.vim to UNIX format … dos2unix: converting file colors/bw.vim to UNIX format … dos2unix: converting file colors/c.vim to UNIX format … dos2unix: converting file colors/camo.vim to UNIX format … dos2unix: converting file colors/candy.vim to UNIX format … dos2unix: converting file colors/caramel.vim to UNIX format … dos2unix: converting file colors/coffee.vim to UNIX format … dos2unix: converting file colors/colorer.vim to UNIX format … dos2unix: converting file colors/colorscheme_template.vim to UNIX format … dos2unix: converting file colors/cool.vim to UNIX format … dos2unix: converting file colors/dante.vim to UNIX format … dos2unix: converting file colors/darkblue.vim to UNIX format … dos2unix: converting file colors/darkdot.vim to UNIX format … dos2unix: converting file colors/darkocean.vim to UNIX format … dos2unix: converting file colors/darkslategray.vim to UNIX format … dos2unix: converting file colors/dawn.vim to UNIX format … dos2unix: converting file colors/default.vim to UNIX format … dos2unix: converting file colors/denim.vim to UNIX format … dos2unix: converting file colors/desert.vim to UNIX format … dos2unix: converting file colors/elflord.vim to UNIX format … dos2unix: converting file colors/emacs.vim to UNIX format … dos2unix: converting file colors/evening.vim to UNIX format … dos2unix: converting file colors/fine_blue.vim to UNIX format … dos2unix: converting file colors/fnaqevan.vim to UNIX format … dos2unix: converting file colors/fog.vim to UNIX format … dos2unix: converting file colors/golden.vim to UNIX format … dos2unix: converting file colors/ibmedit.vim to UNIX format … dos2unix: converting file colors/ironman.vim to UNIX format … dos2unix: converting file colors/koehler.vim to UNIX format … dos2unix: converting file colors/lanzarotta.vim to UNIX format … dos2unix: converting file colors/lilac.vim to UNIX format … dos2unix: converting file colors/manxome.vim to UNIX format … dos2unix: converting file colors/midnight.vim to UNIX format … dos2unix: converting file colors/midnight2.vim to UNIX format … dos2unix: converting file colors/morning.vim to UNIX format … dos2unix: converting file colors/murphy.vim to UNIX format … dos2unix: converting file colors/navajo-night.vim to UNIX format … dos2unix: converting file colors/navajo.vim to UNIX format … dos2unix: converting file colors/night.vim to UNIX format … dos2unix: converting file colors/nightshimmer-theme.vim to UNIX format … dos2unix: converting file colors/nightwish.vim to UNIX format … dos2unix: converting file colors/northsky.vim to UNIX format … dos2unix: converting file colors/oceanblack.vim to UNIX format … dos2unix: converting file colors/oceandeep.vim to UNIX format … dos2unix: converting file colors/pablo.vim to UNIX format … dos2unix: converting file colors/peachpuff.vim to UNIX format … dos2unix: converting file colors/potts.vim to UNIX format … dos2unix: converting file colors/print_bw.vim to UNIX format … dos2unix: converting file colors/rainbow_autumn.vim to UNIX format … dos2unix: converting file colors/rainbow_breeze.vim to UNIX format … dos2unix: converting file colors/rainbow_fine_blue.vim to UNIX format … dos2unix: converting file colors/rainbow_fruit.vim to UNIX format … dos2unix: converting file colors/rainbow_neon.vim to UNIX format … dos2unix: converting file colors/rainbow_night.vim to UNIX format … dos2unix: converting file colors/rainbow_sea.vim to UNIX format … dos2unix: converting file colors/redblack.vim to UNIX format … dos2unix: converting file colors/ron.vim to UNIX format … dos2unix: converting file colors/sand.vim to UNIX format … dos2unix: converting file colors/scite.vim to UNIX format … dos2unix: converting file colors/sean.vim to UNIX format … dos2unix: converting file colors/seashell.vim to UNIX format … dos2unix: converting file colors/shine.vim to UNIX format … dos2unix: converting file colors/taqua.vim to UNIX format … dos2unix: converting file colors/tomatosoup.vim to UNIX format … dos2unix: converting file colors/toothpik.vim to UNIX format … dos2unix: converting file colors/torte.vim to UNIX format … dos2unix: converting file colors/transparent.vim to UNIX format … dos2unix: converting file colors/whitedust.vim to UNIX format … dos2unix: converting file colors/wintersday.vim to UNIX format … dos2unix: converting file colors/xemacs.vim to UNIX format … dos2unix: converting file colors/xian.vim to UNIX format … dos2unix: converting file colors/zellner.vim to UNIX format … dos2unix: converting file colors/zenburn.vim to UNIX format … [codemonkey@gucho .vim]$
vim and gvim color schemes
You will most likely notice that some color schemes do not change much colors in your console
vim. That is because they are most probably designed for GUI version of Vim, calledgvim.Try executing “
gvim +'colorscheme peachpuff' main.pl” to see how gvim looks with selected color scheme.
Now you can try all those color schemes one by one with “:colorscheme something” and choose the one you like best. When you are done choosing, add line “colorscheme something” to your .vimrc.
If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_06.txt.
It is an often need to comment or uncomment blocks of code during the development cycle. While there is a way to do it in Vim without any additional configuration, I try to make life as easy as possible and install the BlockComment plug-in by Chris Russell.
Let’s download BlockComment.vim from http://www.vim.org/scripts/script.php?script_id=473 and copy it into .vim/plugin/ directory. This plug-in automatically provides us with two mappings: “.c” for commenting code and “.C” for uncommenting code back.
Vim supports editing of several files simultaneously. One can start Vim as “vim main.pl main2.pl” and then use “:next” and “:previous” to navigate through open files (called “buffers”). It is also possible to open files for editing without quiting Vim every time. For that, one should use simple “:e main2.pl” command, where main2.pl is the name of needed file.
There are, as usual, better (more convenient) ways to work with files and buffers. Vim website lists few plug-ins which can handle only files, or only buffers, or both at the same time. One of those plug-ins is winmanager by Srinath Avadhanula. Let’s grab winmanager from http://www.vim.org/scripts/script.php?script_id=95.
Vim’s winmanager plug-in can make use of bufexplorer plug-in by jeff lanzarotta availalbe from http://www.vim.org/scripts/script.php?script_id=42.
Installation is as usual - saving, unziping, and dos2unixing. Since we don’t want to always have file/directory browser turned on, lets add a mapping line to our .vimrc to “:WMToggle” by F2.
" This is for winmanager map <F2> :WMToggle<CR>
If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_23.txt.
If you ask me, I am almost happy. The last thing that I am missing is something that will ease up my code browsing. I need a fast way of switching between different parts of my code and hierarchical view of it. Once again I go fishing to Vim web site and get myself a nice looking taglist plug-in by Yegappan Lakshmanan from http://www.vim.org/scripts/script.php?script_id=273. This one is not even an archive! You just need to copy it into your .vim/plug-in directory. Let’s map “:Tlist” command to F3 key.
" This is for taglist map <F3> :Tlist<CR>
One annoying thing that I find about taglist is that it resizes the terminal window when possible. I prefer to switch this feature off by add modifying my .vimrc in the following way.
" This is for taglist let Tlist_Inc_Winwidth = 0 map <F3> :Tlist<CR>
If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/tagsrch.txt.
If you use Embperl perl module for developing dynamic content websites, then you will need to download Embperl syntax highlighting plug-in developed by Lukas Zapletal. These steps are similar for setting up highlighting for any other programming language that you might use and which is not supported out of the box.
Embperl syntax highlighting plug-in is located at http://www.vim.org/scripts/script.php?script_id=61. Download it and unzip it in your .vim/ directory. Again, passing all new files through dos2unix is a good idea, if you are on a UNIX/Linux box as I am. vimrc_example shipped with the archive contains the example of configuration that you’ll need to put into your .vimrc.
[codemonkey@gucho .vim]$ ls colors colors.zip Embperl_Syntax.zip [codemonkey@gucho .vim]$ unzip Embperl_Syntax.zip Archive: Embperl_Syntax.zip inflating: colors/embperl_yellow.vim creating: syntax/ inflating: syntax/embperl.vim inflating: vimrc_example [codemonkey@gucho .vim]$ cat vimrc_example “let perl_fold=1 augroup filetypedetect autocmd! BufNewFile,BufRead *.epl,*.phtml setf embperl augroup END autocmd BufNewFile,BufRead *.epl,*.phtml colorscheme embperl_yellow
Embperl color scheme
Embperl syntax highlighting plug-in uses it’s own color scheme, so don’t worry if you see colors different from the ones that you have expected.
Most of Integrated Development Environments (IDE) try to simplify write-compile-debug cycle. One of the things which can make the cycle easier is automatic cursor positioning to the place in the code where error occurred. Vim can do this for almost any language and compiler. If you know the format that your compiler spits out, then you can configure Vim to parse those errors and position the cursor for you. Since I am not the first Perl developer who uses Vim, I assumed that someone already wrote the compiler error syntax parser (sounds horrifying, isn’t it?).
Let’s once again download it from Vim web site - http://www.vim.org/scripts/script.php?script_id=56. Installation instructions are simple: just copy perl.vim (developed by Lukas Zapletal) into your .vim/compiler/ directory. Now we need to specify for which files we want Vim to use our new perl compiler scripts. This is easily done by adding the following lines to .vimrc.
" Use perl compiler for all *.pl and *.pm files. autocmd BufNewFile,BufRead *.p? compiler perl
Now you can use “:make” to check your code for errors. If you do have problems in your code, then Vim will position the cursor on the line with the first problem. You can use “:cnext” and “:cprevious” to go through other error messages. “:clist” will show a list of all errors.
If you need more information on this topic, read file /usr/share/doc/vim-common-6.1/docs/usr_30.txt.
Yet another feature provided in most IDEs is on-line documentation. Vim helps developers even with that. By default, Vim comes with system manual support on all UNIX boxes. This comes very handy when you use system commands in your scripts and need to check command line parameters. Just position the cursor on the word that you are interested in and press K. Vim will execute “man word“, where “word” is the word under the cursor. This is helpful but not as much as we need it.
Let’s visit Vim site again and download Perldoc plug-in (developed by Colin Keith) from http://www.vim.org/scripts/script.php?script_id=209. unzip perldoc.zip and run all extracted files through dos2unix. It’s a good idea to add a F1 mapping to “:Perldoc” in your .vimrc.
" This is for perldoc.vim autocmd BufNewFile,BufRead *.p? map <F1> :Perldoc<cword><CR> autocmd BufNewFile,BufRead *.p? setf perl autocmd BufNewFile,BufRead *.p? let g:perldoc_program='/usr/bin/perldoc' autocmd BufNewFile,BufRead *.p? source /home/codemonkey/.vim/ftplugin/perl_doc.vim
If you are using a newer version then I do, then you skip the last line.
Now, whenever you hit F1 while in the perl file, “:Perldoc” will get executed for the word that you have under the cursor, your current window will split horizontally and you’ll see appropriate perldoc page.
After installation of this plug-in I have noticed that syntax highlighting in few of my programs broke. After a quick look, I understood that that happened because of my extensive usage of underscore (”_”) character in procedure names. I had to fix it by simply adding underscore (”_”) character to the list of keyword characters on line 14 in file .vim/ftplugin/perl_doc.vim.
" Adds / and . as used in requires. " setlocal iskeyword=a-z,A-Z,48-57,:,/,. " Adds / and . as used in requires. Also adds _ as used in procedure names. setlocal iskeyword=a-z,A-Z,48-57,:,/,.,_



34 responses so far ↓
1 oleg // May 12, 2004 at 6:26 pm
great article. thanks!
2 SR // May 13, 2004 at 10:14 pm
Really Great Article.
Easy to understand and with complete information and links. Thanks
3 Axioplase // May 14, 2004 at 12:24 am
Yes!
thanks you!
Though i wouldn’t spit on a more detailed index, neither on some more blank lines, to have the reading of this article easier.
4 noahpb // Jun 9, 2004 at 11:57 pm
Very informative. Thanks for taking the time to write this up.
It’s great to see explanations of Vim features I wasn’t aware of.
5 fo0 // Jun 12, 2004 at 12:04 am
great thanks
6
HoRai
// Jun 26, 2004 at 10:43 pm
Great!
This turns me into a vim killer!
I only disagree on the fact that it’s easy to browse on the vim website.
I’ve been searching for this block commenting tip and had to read you article to succeed.
7 Alex // Aug 1, 2004 at 11:00 am
Your article was the sole reason I had the courage to start using VIM. I have never looked back. Thanks!
Now if I could only stop hitting escape on the command line out of habit…
8 nothingmuch // Aug 18, 2004 at 12:32 am
Alex - try bash’s Vi editing mode.
9 jbWare // Sep 16, 2004 at 4:00 am
Great article (++)
10
Venkatraman.D
// Oct 21, 2004 at 12:50 pm
it is superb article… Whenever i thought of reading VIM , usually it will end up in mishap… but this tutorial is ultimate….
11
Nicola Worthington
// Oct 28, 2004 at 6:29 pm
Can I marry you? You’re wonderful.
**licks you for wonderful vim and perl niceness**
12
Ben Prew
// Jan 6, 2005 at 7:42 am
What about adding support for automatically recognizing .t files as perl test files?
1. create a directory called ftdetect in .vim
2. create a file with a .vim extension (I named mine perl_test.vim)
3. Put this line in it:
au BufRead,BufNewFile *.t setfiletype=perl
Now, whenever I enter a .t file, Vim assumes it a perl file.
13 chocolateboy // Mar 5, 2005 at 8:52 pm
What Nicola Worthington said + a lazier version of the above:
au BufRead,BufNewFile *.t set syntax=perl
14
Bert
// Mar 8, 2005 at 6:55 pm
How do i switch between the taglist pane and the main editor without using a mouse, is there a keyboard shortcut so i can togle between them?
15
Leonid Mamchenkov
// Mar 9, 2005 at 5:44 pm
16 adong // Mar 19, 2005 at 2:27 pm
‘za’ and ‘za’ again to folding and unfolding.
17 Blog of Leonid Mamchenkov » Blog Archive » Fixed ‘Vim for perl developers’ for Konqueror // Apr 12, 2005 at 10:15 pm
[...] » Fixed ‘Vim for perl developers’ for Konqueror Vim for perl developers was terrible broken when viewed with Konqueror. I gu [...]
18
Anno Siegel
// May 12, 2005 at 8:39 pm
Concerning “Perl syntax compiler”, there is an alternative that takes things from the Perl side.
If you
use Vi::QuickFix(from CPAN) somewhere, Perl will write a file errors.err for Vim. The commands “:cf”, “:cn”, etc. are immediately available.Anno (Author of Vi::QuickFix, in case you wonder why I care)
19 모꿈ì?˜ 쿵딱쿵딱 장난ê°? 공작실 » Blog of Leonid Mamchenkov » Blog Archive » Vim for Perl developers // Jun 17, 2005 at 3:34 am
[...] 6ì›” 17, 2005 at 9:34 am · Filed under development, perl Blog of Leonid Mamchenkov » Blog Archive » Vim for Perl developers Leonid M [...]
20
Edward WIJAYA
// Nov 6, 2005 at 10:37 am
Have you considered “perl-support” by Fritz Mehner? As a more complete version from C.Keith’s.
http://www.vim.org/script.../s.....ipt_id=556
21
Leonid Mamchenkov
// Nov 7, 2005 at 11:51 am
22 骑马扇风 » vi 颜色æé… // Dec 6, 2005 at 11:44 am
[...] vim for perl developers http://mamchenkov.net/wor.../v.....evelopers/ [...]
23
Jagadeesh
// Jan 21, 2006 at 1:48 pm
Greate help for perl developpers……..
24
marc
// Feb 1, 2006 at 12:24 am
Hi, your links don’t work anymore. I’d love to try. Can you fix them?
Marc
25
Leonid Mamchenkov
// Feb 1, 2006 at 12:55 am
Thanks for letting me know. I’ll fix them shortly. In the mean time, please use page navigation to go around. You can find page links just after the article and above the comments - they look like this “Pages: 1 2 3 4″.
26
ivan
// Aug 13, 2006 at 8:17 pm
Pretty good! I just now realized the beauty of VIM. Another pico fan converted *sigh*
27
naboj
// Aug 29, 2006 at 1:18 am
Very good article. This was the final reason to convert me to vim
28
Luca
// Oct 18, 2006 at 11:40 am
Very useful. Thank you.
29
miguel
// Nov 14, 2006 at 8:32 pm
great article.
here are a few features that I can’t live without,
:let &backspace=2 # when you go into insert mode you can backspace over anything even if you move the cursor around to other lines
:au BufReadPost * if line(”‘\”") > 0 && line(”‘\”")
30
Anonymous
// Nov 22, 2006 at 9:00 am
Great article, you\’ve really done a lot of hard work. Thanks for sharing.
31 prozz’s blog » Blog Archive » Vim Zen // Feb 4, 2008 at 2:42 pm
[...] Here you can find great article about Vim editing in practice. Recommended for nonbelievers. [...]
32
Jagadeesh
// Feb 21, 2008 at 8:02 am
Can we have something like, on saving file [ on using :w] it should sople source code.
33
Jagadeesh
// Feb 21, 2008 at 8:02 am
Can we have something like, on saving file [ on using :w] it should compile source code.
34
Jagadeesh
// Feb 21, 2008 at 8:14 am
Hey,
I got something like this. just append following line to .vimrc file
autocmd BufWritePost *.pl !perl -c %
when you save your perl file, syntax will be verified
Leave a Comment