要删除几行文本,当你不知道的行删除的确切数量,你试试10dd,5dd,3dd直到您删除所有行。
相对行号解决了这个问题,假设我们有一个包含以下内容的文件:
sometimes, you see a block of text. You want to remove it but you cannot directly get the exact number of lines to delete so you try 10d , 5d 3d until you remove all the block.
进入正常模式: Esc
现在,执行:set relativenumber。完成后,文件将显示为:
3 sometimes, you see a block of2 text. You want to remove1 it but you0 cannot directly get the1 exact number of2 lines to delete3 so you try4 10d , 5d5 3d until6 you7 remove all the block.
0当前行的行号在哪里,它还在相对号前面显示了真实的行号,所以现在您不必估计当前行的行数就可以剪切或删除,也可以更不用说计算一个一。
现在,您可以像执行常规命令一样6dd,并且可以确定行数。
您也可以使用同一命令的缩写形式:set rnu来打开和:set nornu关闭相对数字。
如果你也:set number还是有:set number已经打开,你会得到光标是在该行的行号。
3 sometimes, you see a block of 2 text. You want to remove 1 it but you 4 cannot directly get the 1 exact number of 2 lines to delete 3 so you try 4 10d , 5d 5 3d until 6 you 7 remove all the block.