Sunday, June 4, 2006

Vim, lately?

As I write this, Vim 7 is making waves as the next great thing in Open Source software; although it's not yet available in most package management systems. Fortunately, Vim is easy to compile from source. I used the following to compile the source on my Ubuntu laptop:

sudo apt-get build-dep vim-gtk
sudo aptitude install xlibs-dev
svn co https://svn.sourceforge.net/svnroot/vim/vim7
cd vim7
./configure --enable-gui --enable-perlinterp
--with-compiledby='Codefix Consulting <garrison@codefix.net>'
make && sudo make install

IMHO, Vim 7 sports two features that make it an urgent necessity worth compiling. First is tab support. Vim has traditionally had clumsy methods for editing multiple documents, either serially or by dividing the screen into smaller windows. With tabs (vim -p *) you'll see a row of tabs at the top of the screen, one per file, switching tabs is as easy as point and click or 'gt' in command mode.

The other feature worth getting to know is spell check. Vim 7 casts off the aspell/ispell bindings in favor of a built in spell checker, activated with ':set spell'. Use the following to work with the spell check in command mode:

]s next mispelling
[s previous mispelling
z= spelling suggestions
zg add word to dictionary
zug remove word from dictionary

Vim has many great features and I recommend O'Reilly's "Learning the vi Editor" if you're interested in discovering more. Because the sixth edition only covers Vim through version 5, here are a few commands to get started with folding, a remarkable feature introduced in Vim 6:

zf fold selected text
zf% fold here to closing brace
zz I like to map this to zf%
zo open this fold