Vim’s relativenumber
Dev tip 0/99
Aug 24, 2017 · 2 min read
My editor of choice is vim — specifically MacVim. One of my favorite settings that enables faster movement in files is the relativenumber setting:
...'relativenumber' 'rnu' boolean (default off)Show the line number relative to the line with the cursor in front of each line. Relative line numbers help you use the |count| you can precede some vertical motion commands (e.g. j k + -) with, without having to calculate it yourself. Especially useful in combination with other commands (e.g. y d c < > gq gw =).When the 'n' option is excluded from 'cpoptions' a wrapped line will not use the column of line numbers (this is the default when
'compatible' isn't set).The 'numberwidth' option can be used to set the room used for the line number.When a long, wrapped line doesn't start with the first character, '-' characters are put before the number.See |hl-LineNr| for the highlighting used for the number.
When setting this option, 'number' is reset....
Instead of guessing how many lines above or below my cursor the next line I want to edit is, I can look to the number column and see exactly lines I need to jump. Here’s what realtivenumber (and number) look like in my editor.

This works wonderfully for yanking and deleting! Say I want to delete everything from my current line (line 30 in the image) to the line with set laststatus=2. I look to the line number column and see it’s 7 lines down. So I type 7dj and the lines are nixed.
