Vim Customisation

10 AM April 30, 2004

I wrote this piece in February. I didn’t post at the time because I wanted to link to the online Vim help files at vimdoc.sourceforge.net, but it wasn’t working properly. Two months later, it is still not working properly, so I’m posting anyway.

Everybody’s DNS seems to have switched to point to this new server, so this will be the last of “Unseen Alan”.


Vim is my all-time favourite text editor. Productivity wise, I find it better than every IDE I’ve ever used, excepting Eclipse, which I prefer for Java1.

I’m currently working on a C++ project. When we started here, we spent a few days setting up the development environment, including Vim. This is what we did:

  • Installed a cvs plugin, which lets us see color-highlighted diffs.
  • Set up tags over our source code and the library header files.
  • Set standard C++ indenting and comment styles in a project-wide .vimrc file.
  • Taught Vim how to interpret the error messages from the compiler, linker, and database preprocessor.

Function keys are all set up too:

  • F2 opens a file explorer
  • F3 swaps between a .cpp file and the related .h file
  • F4 does the same as F3, but opens the related file in another window
  • F5 kicks off a build
  • F6 shows build errors
  • F7 and F8 navigate to the next/previous build error
  • F11 and F12 navigate to the next/previous tag

Some Vim features that have been helpful are:

  • the ‘find’ command, because I am too lazy to remember what directory any given file is in,
  • ‘grep’, which searches all of our project files by default,
  • CTRL-N and CTRL-P, auto-completion, which I use constantly.

Would I recommend Vim to every programmer? No. Its vi-derived, modeful, “Look Ma, No Arrow Keys Runs On A VT100, A Mac And Anything In Between interface is daunting for those who haven’t had to use vi at some stage. But for a significant fraction of the development community, Vim is the ant’s pants.


1 Though I haven’t used IDEA. Or Emacs.

By alang | # | Comments (2)
(Posted to Rants, Software Development and javablogs)

Comments

At 14:19, 30 Apr 2004 Dave wrote:

vim (or rather gvim) rules all! :find and :grep are so useful and so much more powerful than any ide I've ever used. The completion is great, because while it isn't "smart", it can be used for anything, writing comments, etc.

And dont' forget abbreviations. I type "ITER" and I get a nice for loop that iterates over an Iterator with my cursor in the right place to type the name of the list. I type "FOR" and get a nice for-loop for iterating an array.

And macros! I type ^Xj on any private method and getters and setters are added. Very handy and very flexible. No clicking next or having it create get/set for every variable (unless you want).

The best thing is that you can use it for ANY text-based thing, including XML, PERL, LaTeX, and you get the exact same editing experience. No pinin away for feature XXX in your XML editor that you have in your Java IDE. Everything, everywhere.

That said: I think you are crazy to use all those retarded function keys. You will increase efficiency by mapping things to control or alt sequences on your keyboard. Never leave the home keys! For me to make, I do Ctrl-X and then m.

(#)
At 14:26, 30 Apr 2004 ha ha wrote:

I like to set up ctrl-x-j-v for make, and alt-[-]-s for debug this symbol, and then ctrl-alt-1-f-p to indent a line, you see, it leaves plenty of space for the next key assignment I want. I'm thinking of alt-ctrl-6-h-c for coffee with one sugar, alt-ctrl-9-a-g for a headjob...

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green