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.

Share:
7,520

Related videos on Youtube

Alex
Author by

Alex

Updated on September 17, 2022

Comments

  • Alex
    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
      Ton van den Heuvel over 13 years
      Start by using k and j to go up and down.
    • Alex
      Alex over 13 years
      Why should I use j/k to go up down?
    • Sasha Chedygov
      Sasha Chedygov over 13 years
      Because then you can keep your fingers on the home row.
  • user5249203
    user5249203 over 13 years
    The second <key>j</key> should be a <key>k</key>