In vim's visual mode (type "v"), how do I select multiple lines?
7,520
Solution 1
Same as normal mode; use <n>G
to go to a specific line.
Also, ShiftV.
Solution 2
{
and }
are very handy motions, they go respectively to the beginning or end of a paragraph.
Use v
then }
and you've selected all the paragraph until the end in two key strokes.
Alternatively you can use text-objects.
Basically,
vip
selects the current paragraph,
vis
selects the current sentence,
etc
See :help text-objects
for more
Solution 3
Same as normal mode; use <n>
plus one movement operator:
- G to go to line
n
- j to go down
n
lines - k to go up
n
lines - w to go right
n
words
etc. see :help motion
and get familiar with that.
Related videos on Youtube
Author by
Alex
Updated on September 17, 2022Comments
-
Alex over 1 year
What are the shortcuts that I need to know, to make it snap snap?
Right now, all I do it the up/down arrow...it's noobish.
-
Ton van den Heuvel over 13 yearsStart by using k and j to go up and down.
-
Alex over 13 yearsWhy should I use j/k to go up down?
-
Sasha Chedygov over 13 yearsBecause then you can keep your fingers on the home row.
-
-
user5249203 over 13 yearsThe second <key>j</key> should be a <key>k</key>