This is my attempt to provide a clear and simple instructions on adopting Vim text editor for programming needs. I am using Perl as the programming language in the examples, but most of this document will apply equally for any other programming language.
Update: This post was translated into Portuguese by Alceu Rodrigues de Freitas Junior.
This document is my attempt to provide a clear and simple instructions on adopting Vim text editor for programming needs. I am using Perl programming language as specific example, although most of this document will apply equally for any other programming language.
Some people may argue that Vim does not need any additional configuration to cover programming needs, while others will say it will never be as good as some Integrated Development Environments (IDEs). I am not going to argue about these two points of view, but rather provide several tips on how to bring a simple text editor, as seen by some, closer to look and feel of an IDE, as needed by others.
Who should read this document?
First of all, this document is for people who are already using Vim for their programming tasks. Those people who feel that there is something missing in Vim should definitely read this document. People who recently stopped using Vim due to the reason that something was not there should also read this document.
I assume that the reader has Vim installed on the system and is comfortable with simple text editing in Vim.
Another assumption is that the reader has at least basic experience in configuring Vim by means of the .vimrc configuration file.
I assume that the reader is using a UNIX/Linux machine for Vim editing sessions. Otherwise, shell command line examples should be taken as a pseudo code for algorithm.
The last but the least assumption is that the reader has access to the Internet and knows how to browse web sites and download files.
Document is separated into two parts: “Basic Configuration” and “Advanced Configuration“. “Advanced Configuration” is further split into “Common Configuration” and “Perl-Specific Configuration“.
“Basic Configuration” contains examples of simplest Vim configuration that does not even require Internet connectivity. These are usually plain Vim configuration options which are built-in.
“Advanced Configuration” contains examples Vim plug-in installation and configuration. You will need Internet connectivity to follow this section.
If you use Vim for your programming tasks, but do not use Perl programming language, then “Common Configuration” section is for you. Examples in “Perl-Specific Configuration” section can be used for extending Vim support for other programming languages.
In order to provide a guaranteed working examples, I have created a new user “codemonkey” on my fully updated RedHat Linux 7.3 home server. This user has no prior .vimrc configuration file and uses only the system-wide default file, which was not modified by me in any way. RedHat’s vim-6.1 version is installed on the server with no changes what-so-ever.
I have created an empty .vimrc in /home/codemonkey/ directory, which is a home directory for the “codemonkey” user. I have also created user specific Vim directory structure as follows:
[codemonkey@gucho codemonkey]$ # Which version of Vim is installed? [codemonkey@gucho codemonkey]$ rpm -qa | grep -i vim vim-minimal-6.1-18.7x.2 vim-common-6.1-18.7x.2 vim-enhanced-6.1-18.7x.2 [codemonkey@gucho codemonkey]$ # In which directory am I now? [codemonkey@gucho codemonkey]$ pwd /home/codemonkey [codemonkey@gucho codemonkey]$ # User-specific Vim configuration [codemonkey@gucho codemonkey]$ touch .vimrc [codemonkey@gucho codemonkey]$ mkdir .vim [codemonkey@gucho codemonkey]$ mkdir .vim/colors [codemonkey@gucho codemonkey]$ mkdir .vim/compiler [codemonkey@gucho codemonkey]$ mkdir .vim/doc [codemonkey@gucho codemonkey]$ mkdir .vim/ftplugin [codemonkey@gucho codemonkey]$ mkdir .vim/plugin [codemonkey@gucho codemonkey]$ mkdir .vim/syntax
Each feature installation and/or configuration is explained separately and can be done independently of the others. Screenshots are provided, where appropriate.
Vim has a large community with a lot of friendly and supportive members. If you are using Vim or just planning to do so, I suggest that you subscribe to Vim mailing list at http://www.vim.org/community.php.
Visit the Vim website for a collection of Tips and Plug-ins at http://www.vim.org/.
Vim is shipped with an extensive documentation which you can find in /usr/share/doc/vim-common-6.1/docs/directory (you path may vary slightly). I have put mentioned documentation files from this directory where appropriate.



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