Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: how to stay in visual mode after executing a command

Tags:

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.

like image 642
Nick Redmark Avatar asked Jan 17 '11 07:01

Nick Redmark


People also ask

How do I go into visual mode in Vim?

To get into the Vim Visual Line mode, press “Shift+V” while you are in Vim's Normal mode.

How do I select a visual block in vim?

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.

Does vi have visual mode?

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 .


1 Answers

  • 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.

like image 100
Xavier T. Avatar answered Sep 19 '22 18:09

Xavier T.