“Knowledge Management with Vim” is a three-part series showing you how to use Vim for managing and manipulating textual information.

astronaut3

I’ve been using Vim for writing articles, memos, to-do-lists - just about everything - for about one year now. For the uninitiated, Vim is an extended version of Bill Joy’s vi, a text editor first published in 1976 (Vim is an acronym for “Vi IMproved”). Explaining why one chooses this over that editor tends to escalate into religious wars, so I’ll just briefly summarize why I like code that’s older than myself.

First of all, it has no GUI (Graphical User Interface). Yeah, that’s an advantage. No stupid icons to decipher, no metaphors that clog my brain, no plastic rodent that needs pushing around. Instead, Vim differentiates between multiple modes, all of which can be accessed via keyboard commands. You want to input text? You enter insert mode (press i). You want to load a file, cut & paste or switch to a different window? You enter normal mode (press Esc or Ctrl+c). If you think that sounds like playing the piano, you’re half-right.

Memorizing each and every command can be troublesome at first. Instead of selecting a sentence with your mouse and pressing Ctrl+c (which effectively copies the text to the clipboard in regular GUI-editors), a VIM user would press y+) in normal mode. Copying a paragraph would be accomplished with y+{, copying a line with yy, deleting a line with dd. And so on and so forth. You can browse this graphical cheat sheet based tutorial for a quick introduction to the basic set of operations.XXXXXXSo on the one hand you’re creating less cognitive strain by not switching between mouse and keyboard and deciphering metaphors/icons. This, you might argue, is outweighed by having to learn a seemingly never-ending series of arcane commands. In which case you are forgetting one thing: speed. Starting macros & scripts, piping text to external programs, manipulating strings of characters in every way possible - all done near-instantaneously by pressing the appropriate key-combo.

The fact that vi is installed on almost every UNIX-box, makes Vim the first choice for administrators. Sure you can use Ultraedit with this and that plugin, but why bother? Vim features a healthy community of developers and users, providing support and additional features through scripts and plugins. For those that wind up living inside Vim, vimperator and ViEmu will make Firefox and Microsoft Office behave in very similar ways. (The picture above was taken in Berlin, near Görlitzer Bahnhof)