Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let vim use relative line numbers counting from 1 instead of 0

Tags:

vim

I've been exploring vim some more in order to be able to use it better and while doing so, I've re-activated the showing of the line numbers with the relative line numbers active.

So my .vimrc contains following lines:

" Set line-numbers
set nu
set relativenumber

This all works nicely, though vim starts counting the current line from 0, while I like it to count from 1.

So currently it looks like this:

 2 " Something else
 1 
3  " Set line-numbers
 1 set nu
 2 set relativenumber

Note: The 3 is the current line number.

Let's assume that I like to cut my line number config, I have to use the command 3dd while the relative line number states 2. Does anyone know how to change this to:

 3 " Something else
 2 
3  " Set line-numbers
 2 set nu
 3 set relativenumber

JVApen

like image 955
JVApen Avatar asked Nov 07 '15 11:11

JVApen


1 Answers

The counting is built into Vim's core; you'd have to change the source code and recompile your custom binary. Alternatively, there's the RltvNmbr.vim plugin, which emulates the setting in Vimscript. By modifying that, you'd avoid the recompilation, but only get an emulation that's far from perfect. Better adapt to Vim's way of counting :-)

like image 138
Ingo Karkat Avatar answered Oct 04 '22 20:10

Ingo Karkat