Absolute, relative and hybrid line numbers in Vim

Absolute, relative and hybrid line numbers in Vim
Absolute, relative and hybrid line numbers in Vim

To show line numbers in Vim is easy: set number or set nu

Many movement, yank and delete operations in Vim work on relative line numbers. For example, to delete the next 5 lines the command d5j can be used. To aid such operations, many users prefer to view relative line numbers: the current line is 0 and the lines moving up and down from current line are incrementally numbered.

To show relative line numbers in Vim: set relativenumber or set rnu

Vim 7.4 adds a hybrid mode for line numbers: the current line shows the absolute line number while the rest show the relative line number. I find this very useful.

To turn on hybrid line number, set both the number and relativenumber options.

Tried with: Vim 7.4 and Ubuntu 14.04

5 thoughts on “Absolute, relative and hybrid line numbers in Vim”

    1. Ben Lindsay: Compare the output of :version in both. Maybe some of the patches used to compile them are different? I don’t have a Mac, so can only guess 🙂

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s