注释块:转自:https://unix.stackexchange.com/questions/120615/how-to-comment-multiple-lines-at-once
To comment out blocks in vim:
- press Esc (to leave editing or other mode)
- hit ctrl + v (visual block mode)
- use the ↑ / ↓ arrow keys to select lines you want (it won't highlight everything - it's OK!)
- Shift + i (capital I)
- insert the text you want, e.g. %
- press Esc Esc.
Ranges:
You can do it with the following commands:
for commenting:
:66,70s/^/#for uncommenting:
:66,70s/^#/Obviously, here we're commenting lines from 66 to 70 (inclusive).
显示行数:
esc
:set number
转跳到某一行(第n 行):
esc
:n
撤销:
esc
u
本文详细介绍在Vim编辑器中如何快速进行多行代码的注释与取消注释操作,包括使用视觉区块模式和范围命令的具体步骤。此外,还介绍了如何在Vim中显示行号及快速跳转至指定行的方法。
626

被折叠的 条评论
为什么被折叠?



