dlo.me

Relative Line Numbers in Vim

I’ve been waiting for ages for relative line numbering (a patch that’s been available for quite a while) to be officially merged into Vim. Well, that day has come :).

Why would you want relative line numbers for your editor? Well, for one, it makes those commands dependent upon line movement exponentially easier. Instead of having to guess how many lines up or down you may want to perform a command over, you’ve got the answer right in front of you. Check it out!

I’m running Snow Leopard, hence the odd ARCHFLAGS='-arch x86_64' prefix. I have a few libraries that have been compiled for both 32-bit and 64-bit architectures, and if I don’t tell Vim which ones to use, it throws a hissy fit.

$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
$ hg checkout vim73
$ env ARCHFLAGS='-arch x86_64' ./configure --enable-pythoninterp \
    --enable-rubyinterp --disable-gui
$ env ARCHFLAGS='-arch x86_64' make
$ sudo make install

This installs your vim in /usr/local/bin/vim by default. To turn on relative line numbering, just run :set rnu. Predictably, to turn it off, use :set nornu.