CTRL+V 在 vi​​m 中做什么?

lee*_*d00 15 vim keyboard-shortcuts

在 viminsert模式下,如果我按 CTRL+V,我会被扔进所谓的状态x mode (^[,^D...),当我按下一个键(例如转义键)时,我会^[^. 它在我的编辑器中也变成绿色。

这是什么,它有什么用途?

mur*_*uru 18

:h i_CTRL-Vi_指示插入模式):

                                                i_CTRL-V
CTRL-V          Insert next non-digit literally.  For special keys, the
                terminal code is inserted.  It's also possible to enter the
                decimal, octal or hexadecimal value of a character
                i_CTRL-V_digit.
                The characters typed right after CTRL-V are not considered for
                mapping.  {Vi: no decimal byte entry}
                Note: When CTRL-V is mapped (e.g., to paste text) you can
                often use CTRL-Q instead i_CTRL-Q.
Run Code Online (Sandbox Code Playgroud)

因此,当您这样做时^v Esc,您实际上是将Esc字符输入到文本中——Vim 不会做它通常会做的事情。该Esc字符通常表示为^[^存在Ctrl,并按Ctrl[通常将让你按等效Esc

Ubuntu的ASCII手册页是在可视化映射有用:

010   8     08    BS  '\b' (backspace)        110   72    48    H
011   9     09    HT  '\t' (horizontal tab)   111   73    49    I
012   10    0A    LF  '\n' (new line)         112   74    4A    J
013   11    0B    VT  '\v' (vertical tab)     113   75    4B    K
014   12    0C    FF  '\f' (form feed)        114   76    4C    L
015   13    0D    CR  '\r' (carriage ret)     115   77    4D    M
...
033   27    1B    ESC (escape)                133   91    5B    [
Run Code Online (Sandbox Code Playgroud)

Shift这种情况下没有任何效果,Vim看到同样的事情,当按下作为CtrlV。尝试CtrlVCtrlVCtrlVCtrlShiftV