Getting the current row number?

后端 未结 6 1578
别跟我提以往
别跟我提以往 2021-01-31 07:15

Is there any key mapping that outputs the current row number of the line being edited? Or, even better yet, can we do formulas based on the output of the key mapping?

I

6条回答
  •  半阙折子戏
    2021-01-31 08:06

    What do you mean by "output"? You can do:

    :echo line(".") + 1
    

    To display the current line number plus 1. You can bind a keystroke with map, eg:

    :noremap  :echo line(".") + 1
    

    To actually insert the data into the buffer:

    :noremap  :execute "normal! i" . ( line(".") + 1 )
    

提交回复
热议问题