In vim while in insert
mode, if I press CTRL+V I'm thrown into what is known as x mode (^[,^D...)
and when I press a key (the escape key for instance) I end up with ^[
or something else that starts with ^
. It also turns green in my editor.
What is this, and what is it used for?
Best Answer
From
:h i_CTRL-V
(thei_
indicates insert mode):So, when you do
^v Esc
, you're literally entering the Esc character into the text - Vim will not do whatever it usually does. The Esc character is usually represented as^[
, the^
being Ctrl, and pressing Ctrl[ will usually get you the equivalent of pressing Esc.The Ubuntu ASCII manpage is useful in visualising the mapping:
The Shift in this case has no effect, Vim sees the same thing as when pressing CtrlV. Try CtrlVCtrlV and CtrlVCtrlShiftV.