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.

Telemachus
  • 181
  • 7
  • 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' – r_31415 Sep 14 '22 at 08:26
  • You may find the following link useful, especially because the gifs help bring relative numbers to life, so to speak. https://jeffkreeftmeijer.com/vim-number/ – Telemachus Sep 14 '22 at 13:53

1 Answers1

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.

Telemachus
  • 181
  • 7
Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37