Reputation: 28562
I have created a line selection in Vim by Shift+V and followed by jjjj.
I can do something against all lines separately like :normal ^i//
, which moves the cursor to the beginning of each line and enter insert mode, then insert two /
.
Is it possible to switch back to normal mode after this?
The example in the question is just to demonstrate the problem and I only want to discuss the Vim usage skills.
I tried :normal ^i//<Esc>A//
in the hope of adding two /
to the end of each line, but it didn't work.
Is this possible?
Upvotes: 0
Views: 66
Reputation: 9445
The :normal
command does not interpret special characters. In your last try, all the chars after i
would be interpreted as normal text then inserted at the beginning of each selected line: //<Esc>A//
.
The Esc character is a special char (actually the ASCII code 27), so you have to ask Vim to insert this char in a different way (because hitting Esc would escape the command line).
In order to do this (either in Command mode or Insert mode), press Ctrl + V then the wanted key, e.g. Esc. This will insert the real <esc>
character in you flow, then perform the desired behaviour.
To summarize:
:normal ^i//
Ctrl + VEscA//
Upvotes: 4