2

Is there any way to select multiple lines in Vim?

For example I want to select line number 1,4,7,8 etc?

I know that I can use V or v to select lines but they select the continuous lines.

For example when I want to add comments # or // etc in different lines. I remember that Sublime-text 2 can do it, so I am wondering if Vim can do it too.

Thanks in advance.

2 Answers 2

1

The multiselect - Create multiple selections and operate on them plugin allows just that. It's great for those cases where a selection via :global would be impossible or too cumbersome.

0

Not possible. However, depending on what you are actually trying to accomplish, try the below things.

If you're trying to highlight multiple lines so they stand out, see :he matchadd()

If you're trying to run a command on multiple lines,

see :he :g 
and :he :v 

For any of these, the "match on this line" regex items may be of use, :he /\%l

1
  • And if you're trying to copy non-sequential lines, use a lower-case register ("a for example) for the first line and the uppercase of the register for the rest ("A). See :help quote_alpha
    – Heptite
    Jan 4, 2014 at 18:56

You must log in to answer this question.

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