vim 中 CTRL+V 的作用是什麼?

vim 中 CTRL+V 的作用是什麼?

在 vim 模式下insert,如果我按 CTRL+V,我就會陷入所謂的狀態x mode (^[,^D...),當我按某個鍵(例如轉義鍵)時,我最終會得到^[或以 . 開頭的其他內容^。它在我的編輯器中也變成綠色。

這是什麼,有什麼用?

答案1

: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.

所以,當你這樣做時^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    [

在這種情況下Shift沒有任何效果,Vim 看到的內容與按 時相同CtrlV。嘗試CtrlVCtrlVCtrlVCtrlShiftV

相關內容