Alignment of current line number in Vim

心已入冬 提交于 2020-12-05 05:35:14

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/46443872/alignment-of-current-line-number-in-vim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!