The "(insert) VISUAL
" mode can be entered by CTRL+O , v starting from insert mode. This enters visual mode, but is displayed as "(insert) VISUAL
" from within vim, and pressing Esc from this mode brings you back to insert mode, not normal mode. The "(insert) VISUAL
" mode is also entered by shifted arrowed keys from insert mode.
Two related questions:
There does not seem to be much documentation on this special mode. Is there an easy way to search for information about it? (edit: I'm aware of what CTRL+O normally does. The interaction with visual mode seems to be special. The first paragraph was the easiest way to refer to what this mode is in the first place, as I don't know of a searchable name for it.)
How do you write
vmap
mappings reliably? Namely, is there a consistent way to leave visual mode and end up in, say normal mode? Or consistently end up in insert mode?
About the second question: you can switch to normal mode from any other using
<C-\><C-n>
. There are no commands for reliably switching to visual or insert modes this way, but if you need only always switching to normal mode after visual it is sufficient. Note that most of the visual-mode mappings are working ini<C-o>v
special mode without modifications.It's documented at
:h Operator-pending
and just below that at:h mode-switching
. Mappings for visual mode will also work for (insert) visual mode. See:h map-modes
for a review of mode mapping.vmap
will map for both visual and select modes,xmap
will map for only visual but not select, andsmap
will map for only select but not visual. In general, you should use thenoremap
versions of these mapping commands to avoid unexpected behavior.For the first question.
CTRL+O in insert mode executes one command and then exits back to insert mode. See
:h i_CTRL-O
.For the second question.
I do not think you there is a reliable way to exit into one mode or another. The most reliable way I think is to start in the mode you want to end in.
In insert mode,
<C-o>
allows you to execute normal mode commands without leaving insert mode. Vim tries to indicate the new state with(insert)
. Since you are now temporally in normal mode, hittingv
puts you in visual mode and Vim tries, again, to indicate the new state with(insert) VISUAL
. Vim is in this state only because of the sequence of commands you performed and, as pointed out by others, that behavior is documented. At this point, it is normal and expected that<Esc>
puts you back in insert mode since that's your original mode.Someone with a deeper Vim understanding than me may be able to tell you if there's a reliable way to end up in
normal
frominsert
->(normal)
->visual
but I'd say that the whole idea sounds fishy to me.Proper usage is:
Basically, you are not supposed to be further than one
<Esc>
away from normal mode.I can't imagine a scenario where using
v
after<C-o>
makes any sense.The best and preferred way to use Vim is to stay out of insert mode as much as possible. Using
<C-o>
to avoid leaving insert mode is a very poor strategy. I have no idea if that's what you do but, if you do it, you should reconsider that approach as soon as possible.But I suspect you are trying to do something else which you, somehow, didn't think we needed to know.