Using vim, I'd like to make a selection of lines and then perform a series of operations on them. The problem is that with each op vim exits visual mode and the lines have to be selected again. Any ideas? Thank you.
To get into the Vim Visual Line mode, press “Shift+V” while you are in Vim's Normal mode.
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
Historically, Vi was designed as a visual mode for the Ex-line editor. The name “Vi” comes from the Ex command, visual , that is used to enter visual mode. The shorthand for that command is vi .
You can use gv
to reselect the last selection quickly.
You can also use |
to chain multiple commands. (See link to Vim Wiki.)
As far as I know there is no way to stay in Visual mode.
If you're having issues with indentation (e.g. selecting two lines), indent them and then having to reselect to indent again, it is quicker to use the .
command to repeat the last command without having to reselect anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With