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.
Asked
Active
Viewed 3,182 times
1 Answers
36
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.

Andrei Bârsan
- 3,473
- 2
- 22
- 46

Xavier T.
- 40,509
- 10
- 68
- 97
-
Thanks! I just googled it in the right way, finding that it had been asked. http://superuser.com/questions/115038/vim-visual-mode-stay-selected – Nick Redmark Jan 17 '11 at 08:06
-
What if I want to tap `x` an unknown number of times to delete the next character (piping makes little sense e.g. `x|x|x|x|x`)? Also +1 for the great tip regarding `.` – stevec Mar 09 '23 at 00:22
-
@stevec generally if you want to repeat a command multiple time you can use "3x" to "x" the three following characters. If you working with text you have to look at motion command like "dw" to delete the next word. And then you can use"3dw" – Xavier T. Mar 10 '23 at 13:04
-
@stevec : try :help motion.txt from within vim to get some details – Xavier T. Mar 10 '23 at 13:07