Getting the current row number?

后端 未结 6 1584
别跟我提以往
别跟我提以往 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:11

    1. Use :set ruler. (Works only in vim) Reference

    It shows the current line and column of the line being edited (line where the cursor lies), at the bottom right corner of the widow.

    1,1

    1. If first line is edited, position is Top.
    2. If last line is edited, position is Bot.
    3. If no scroll is available (both start and end lines are visible), position is All
    4. If no first and last lines are visible, position is the percentage of the document visible.

    To make it permanent, add set ruler in ~/.vimrc file (if file is not there, create one).

    2. Use :set number. (Works in both vi and vim) Reference

    Displays the line number before every line.

提交回复
热议问题