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

Re: select text between brackets or quotes

Expand Messages
  • Tony Mechelynck
    ... Well, it would! Thanks for pointing out a text object I didn t know about. Best regards, Tony. -- We gave you an atomic bomb, what do you want, mermaids?
    Message 1 of 12 , Sep 2, 2007
    • 0 Attachment
      Jürgen Krämer wrote:
      >
      > Hi,
      >
      > Dave Land wrote:
      >> This discussion also reminded me of a very handy mapping that some
      >> here may enjoy...
      >>
      >> I do lots of HTML (actually, JSP) editing in my work, and so frequently
      >> have need to select the "innerHTML" of an pair of tags. I have installed
      >> matchit.vim(1) and set the following in my .vimrc:
      >>
      >> let b:match_words='<\([\:0-9A-Za-z_-]\+\)[^>]*>:<\/\1[^>]*>,<%:%>'
      >>
      >> That match_words string works nearly all of the time for HTML, XML, and
      >> so forth, but occasionally fails if the capitalization of the tags does
      >> not match -- it'll match forward, but not backwards.
      >>
      >> Then, I set the following mapping (I use a Mac, so I chose option-A
      >> because it is similar to command-A, which is "select all"):
      >>
      >> map å Vk%k
      >>
      >> I put the cursor on the first line of the "innerHTML" I want to select,
      >> then use the mapping, which goes up to the opening tag, uses % to find
      >> the appropriate closing tag, then goes up again to deselect the closing
      >> tag. Voilá -- I've selected the contents of a pair of tags.
      >
      > I'm not sure if I have understood the interaction between b:match_words,
      > matchit.txt, and your mapping correctly but wouldn't
      >
      > vit
      >
      > be a much simplet approach to visually select the text between a tag and
      > its matching end tag? There's also
      >
      > vat
      >
      > to select a text and its surrounding tags.
      >
      > Regards,
      > Jürgen
      >

      Well, it would! Thanks for pointing out a text object I didn't know about.

      Best regards,
      Tony.
      --
      We gave you an atomic bomb, what do you want, mermaids?
      -- I. I. Rabi to the Atomic Energy Commission

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Dave Land
      ... It certainly does! I had no idea. I m glad to know about that text object! Unfortunately, Vit and Vat don t work as I would have expected: upon typing the
      Message 2 of 12 , Sep 2, 2007
      • 0 Attachment
        On Sep 2, 2007, at 3:13 AM, Jürgen Krämer wrote:

        > I'm not sure if I have understood the interaction between
        > b:match_words,
        > matchit.txt, and your mapping correctly but wouldn't
        >
        > vit
        >
        > be a much simplet approach to visually select the text between a
        > tag and
        > its matching end tag? There's also
        >
        > vat
        >
        > to select a text and its surrounding tags.

        It certainly does! I had no idea.

        I'm glad to know about that text object!

        Unfortunately, Vit and Vat don't work as I would have expected: upon
        typing the final 't', the selection changes from line-oriented ('V')
        to character-oriented (as though I'd typed 'v' to start).

        But I will be using vit and vat to select text between tags when I
        don't need full-line selections.

        Dave


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tony Mechelynck
        ... After an operator (but not v V Ctrl-V) and before the motion or object, you can use v V or Ctrl-V to force te operator to act characterwise, blockwise or
        Message 3 of 12 , Sep 2, 2007
        • 0 Attachment
          Dave Land wrote:
          > On Sep 2, 2007, at 3:13 AM, Jürgen Krämer wrote:
          >
          >> I'm not sure if I have understood the interaction between
          >> b:match_words,
          >> matchit.txt, and your mapping correctly but wouldn't
          >>
          >> vit
          >>
          >> be a much simplet approach to visually select the text between a
          >> tag and
          >> its matching end tag? There's also
          >>
          >> vat
          >>
          >> to select a text and its surrounding tags.
          >
          > It certainly does! I had no idea.
          >
          > I'm glad to know about that text object!
          >
          > Unfortunately, Vit and Vat don't work as I would have expected: upon
          > typing the final 't', the selection changes from line-oriented ('V')
          > to character-oriented (as though I'd typed 'v' to start).
          >
          > But I will be using vit and vat to select text between tags when I
          > don't need full-line selections.
          >
          > Dave

          After an operator (but not v V Ctrl-V) and before the motion or object, you
          can use v V or Ctrl-V to force te operator to act characterwise, blockwise or
          linewise, respectively: e.g.:

          dVit

          delete inside the tag, and extend the delete to act on whole lines.


          Best regards,
          Tony.
          --
          The reader this message encounters not failing to understand is
          cursed.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Jürgen Krämer
          Hi, ... while in any visual selection mode you can use , , or to change to a different one. So just use VitV or vitV to select complete lines.
          Message 4 of 12 , Sep 2, 2007
          • 0 Attachment
            Hi,

            Dave Land wrote:
            >
            > I'm glad to know about that text object!
            >
            > Unfortunately, Vit and Vat don't work as I would have expected: upon
            > typing the final 't', the selection changes from line-oriented ('V')
            > to character-oriented (as though I'd typed 'v' to start).

            while in any visual selection mode you can use <V>, <v>, or <C-V> to
            change to a different one. So just use

            VitV

            or

            vitV

            to select complete lines.

            Regards,
            Jürgen

            --
            Sometimes I think the surest sign that intelligent life exists elsewhere
            in the universe is that none of it has tried to contact us. (Calvin)

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.