Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I love vim's visual mode. However when I select some text then do something to it the text is then unselected.

For example lets say that I select a block of code and indent it the code is then unselected so if you pressed 4 > instead of 5 > then you have to reselect the code to indent it one more tab.

Is there anyway to not deselect a block of code after preforming an operation? Alternately is there a way to select the same code again (with one keystroke) after an operation has been preformed?

share|improve this question
up vote 27 down vote accepted

There isn't a way to leave it selected, but there is a way to get the same selection back without all that manual labour. Select your stuff, do what you need (let's say, indent it), it will unselect itself, then gv

share|improve this answer
+1 Exactly what I needed! – sixtyfootersdude Mar 1 '10 at 22:22
Glad to help... – Rook Mar 2 '10 at 14:42

Add these two (three with comment) lines to your .vimrc (_vimrc for windows):

"make < > shifts keep selection
vnoremap < <gv
vnoremap > >gv

They cause the shift commands to reselect the visual area after use. VERY handy.

share|improve this answer

Hit the "." (period) in command mode to repeat your last edit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.