Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: move visual selection, not text, up & down lines

Tags:

vim

If I have this line visually selected

Alpha <-- selected
Bravo
Charlie

is there a vim command to move the selected area down, without adding to the original selection?

Alpha
Bravo
Charlie <-- selected

hjkl key will only add lines to your selection. And I didn't see anything in visual's help doc that indicated it could be done.

like image 588
Thomas Avatar asked Jul 11 '12 20:07

Thomas


2 Answers

In selection mode, you can use o (lowercase o) to swap between moving the top and bottom boundary. So you can do this without leaving selection mode using jjojj.

like image 180
Greg Hewgill Avatar answered Oct 13 '22 12:10

Greg Hewgill


This will certainly do it:

jjVV

But it isn't really any different from canceling the original selection first:

escjjV

Or:

VjjV

like image 45
Wayne Avatar answered Oct 13 '22 11:10

Wayne