Vim 中索引的概念

Isa*_*man 1 vim

使用 Vim,如何在连续行上打印数字,例如 1 到 100?

例如

1
2
3


100

Raf*_*cki 5

类型:

1
Run Code Online (Sandbox Code Playgroud)

然后录制一个宏:

qa (start recording a macro stored in register a)
yy (copies the line)
p (inserts that line below)
CTRL+A (increases number by one)
q (stops recording)
Run Code Online (Sandbox Code Playgroud)

接下来,您可以通过以下方式调用该宏 99 次:

99@a
Run Code Online (Sandbox Code Playgroud)