Loading ...
Sorry, an error occurred while loading the content.

Re: Can I select multiple inconsecutive lines?

Expand Messages
  • Tim Chase
    ... The short answer is no . However, you don t specify what you want to do with those lines once you ve multi-selected them. Most of the time I want to do
    Message 1 of 3 , Mar 15, 2013
    • 0 Attachment
      On 2013-03-15 12:20, Benjamin Klein wrote:
      > Dumb question: In linewise visual mode -- or even indeed in visual
      > mode generally -- is it possible for me to somehow select
      > non-following lines or characters, or do I have to make one
      > selection at a time? If I don’t have to, how might I do this?

      The short answer is "no". However, you don't specify what you want
      to do with those lines once you've multi-selected them. Most of the
      time I want to do something like this, a :g command satisfies my
      needs as I can find some pattern that matches the lines of interest
      (or match something that can find the first line of the block, and
      another search that can match the end of the block). So I can do
      things like comment out all the function-bodies where "foo" is being
      called:

      :g/\<foo(/?^{?+;/^}/-s/^/#

      That finds the lines containing "\<foo(", then performs a
      substitution over a range. That range happens to be "search
      backwards from the current (foo call) line for an open-brace at the
      beginning of the line, move forward one line ("+") for the starting
      location of the range; through searching forwards to a closing brace
      at the beginning of the line, moved back one line ("-")". Once you
      start seeing those building-blocks, I find the :g command is much
      easier to assemble what I want, rather than trying to maintain a
      multi-selection.

      There *is* also a plugin[1] that somewhat attempts to mimic a
      multi-region functionality, however I've not used it.

      -tim

      [1]
      http://www.vim.org/scripts/script.php?script_id=4467




      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.