28

I would like to select lines visually.

Usually I'd SHIFT-V and select with j and k to highlight the lines.

How do I do it using a colon-range command? e.g. :10,12<?> to select lines 10 - 12 and enter visual mode with that selection. What should I insert for <?> here?

I'm sure it's easy but I don't know what keywords to web-search/browse help for.

1
  • 10
    How about 10GV12G?
    – jw013
    Jul 18, 2012 at 14:45

1 Answer 1

25

Like jw013 says, you can use the vim movements:

10GV12G
10GV2j

If you still want a range command:

command! -range Vis call setpos('.', [0,<line1>,0,0]) |
                    \ exe "normal V" |
                    \ call setpos('.', [0,<line2>,0,0])
:10,12Vis

For details:

:help command-range
:help setpos(
1
  • 1
    command! -range Vis normal! <line1>GV<line2>G
    – mattn
    Aug 25, 2017 at 16:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .