在vim中被资本混淆了

veh*_*zzz 9 vi vim

每当我想评论一段代码时,我都会遵循这些步骤:

1) Enter Blockwise Visual mode by hitting CTRL-V.
2) Mark the block you wish to comment.
3) Hit I (capital I) and enter your comment string at the beginning of the line. (// for C++)
4) Hit ESC and all lines selected will have 
Run Code Online (Sandbox Code Playgroud)

但是,我不太清楚在那里做了什么. 为什么ESC会导致块中每行的插入.

Nat*_*man 16

块选择模式I告诉VIM切换到插入模式,光标位于块第一行的第一个字符之前.

在第一行上键入的所有字符都将插入所选所有行的前面,就在所选块之前.

您也可以这样做A,除了您将在块之后添加它.

  • 这解释了它比我的答案好得多. (3认同)

hom*_*ast 5

:help I

Insert text before the first non-blank in the line
[count] times.
When the 'H' flag is present in 'cpoptions' and the
line only contains blanks, insert start just before
the last blank.
Run Code Online (Sandbox Code Playgroud)

在每个选定行之前插入

我只能假设使用了“ESC”,因为它不像 ENTER 那样是可打印的字符。