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?

link|improve this question

feedback

3 Answers

up vote 11 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

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

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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