vim中的相对数字

now*_*wox 1 vim

我注意到vim中有关相对数字的奇怪行为:

:设置nu

  1
  2
  3 _
  4
  5
  6
  ~
Run Code Online (Sandbox Code Playgroud)

:设置relativenumber

  2
  1
3   _
  1
  2
  3
  ~
Run Code Online (Sandbox Code Playgroud)

:设置nonu

  2
  1
  0 _
  1
  2
  3
  ~
Run Code Online (Sandbox Code Playgroud)

我问自己为什么有时候我会看到绝对的当前行号,有时我看到0这是无用的.

这种行为是正常的,如何正确numberrelativenumber

Ste*_*fan 5

这是预期的行为.从:help number_relativenumber

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
Run Code Online (Sandbox Code Playgroud)