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?


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


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.