Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alignment of current line number in Vim

Tags:

vim

In Vim I am using relative line numbering and in my .vimrc have highlight CursorLineNr ctermfg=LightGray to make the current line number stand out a bit more.
I was wondering if it's possible to also change the alignment of the current line number? By default it's aligned to the left, but I would like to have it align to the right like the other numbers.

The current line number is aligned to the left

like image 508
Hendrik Avatar asked Sep 27 '17 09:09

Hendrik


1 Answers

The combination of number and rnu option will change the display of line numbers. If you have nonu and rnu, then the current line number will be aligned with other (relative) line numbers, however, the current line number shows always 0.

If you enable both nu and rnu, you got the display style as your screenshot. This cannot be changed.

For detail, pls check

:h number_relativenumber

Related info:

        The 'relativenumber' option changes the displayed number to be
    relative to the cursor.  Together with 'number' there are these
    four combinations (cursor in line 3):

        'nonu'          'nu'            'nonu'          'nu'
        'nornu'         'nornu'         'rnu'           'rnu'

        |apple          |  1 apple      |  2 apple      |  2 apple
        |pear           |  2 pear       |  1 pear       |  1 pear
        |nobody         |  3 nobody     |  0 nobody     |3   nobody
        |there          |  4 there      |  1 there      |  1 there
like image 182
Kent Avatar answered Nov 12 '22 08:11

Kent