Can anyone help me how to put an <esc> command in a vimscript in order to switch from a insert visual mode (selection mode) to the visual mode?
This is my script:
if a:type == "'<,'>"
normal! "\<esc>\<esc>"
normal gvy
let myvariable= @+
endif
explication:
I have selected a piece of text. (I’m now in insert visual mode (=selection mode))
I have to select the same text in visual mode.
Without vimscript I just have to push 2 times the <esc> command and the command gv in normal mode to reselect the selection again and this time I’m in visual mode.
I tried to put the <esc> commands as in above script but it doesn’t work.
You have completely wrong syntax for invocation of
:normal.will execute 14 characters in normal mode, none of them will be escape character: normal does not accept expressions. You have to use
(
\<Esc>also works, but\eis faster to type). I see no reason in having two normal commands here so. But I am still wondering what you do to invoke this script? Without this information the above is likely to prove being completely useless.
PS: I completely agree with @romainl that using easy mode and, more, using mouse in easy mode is completely wrong way of using vim.