The Computer Oracle

Vim visual mode, stay selected

--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Luau

--

Chapters
00:00 Question
00:45 Accepted answer (Score 54)
01:06 Answer 2 (Score 29)
01:31 Answer 3 (Score 16)
01:45 Thank you

--

Full question
https://superuser.com/questions/115038/v...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#keyboardshortcuts #vim #selection #visualmode

#avk47



ACCEPTED ANSWER

Score 54


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




ANSWER 2

Score 29


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.




ANSWER 3

Score 16


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