4

I have been used to absolute line numbers (:set number norelativenumber). I'm unable to find a good reason and utility value for relative line numbers (:set nonumber relativenumber) line or hybrid line numbers (:set number relativenumber).

Can someone help me understand their value?

I am sure there is.

2
  • 1
    From the documentation: 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 =) :h 'relativenumber' Commented Sep 14, 2022 at 8:26
  • You may find the following link useful, especially because the gifs help bring relative numbers to life, so to speak. jeffkreeftmeijer.com/vim-number Commented Sep 14, 2022 at 13:53

1 Answer 1

5

One reason for relative line number is that some Vim command use relative line number or relative range.

A trivial example is 4j that moves 4 line down relative to the current line number.

But there are other commands like :t or :m that copy or move lines that can be used with relative range and relative line numbers.

Move the current line and the next three to start below line 1.

:.,+3m1 

If you want to use such relative ranges and line number it helps to have relative line number shown.

Personally I don't use them very often and I prefer absolute line number too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.