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

Re: Search And Yank

Expand Messages
  • Yegappan Lakshmanan
    Hi, ... You can also use one of the following commands: let @e = matchstr(getline( . ), . {-} ) let @e = matchstr(getline( . ),
    Message 1 of 14 , Feb 1, 2006
    • 0 Attachment
      Hi,

      On 2/1/06, A. J. Mechelynck <antoine.mechelynck@...> wrote:
      > Tim Chase wrote:
      > >> In a script (untested, all on one line):
      > >>
      > >> exe 'normal /\<this\>' . "\r" . '/\<find\>' . "\r" . 'e"ey'
      > >
      > > While I couldn't quite tell if Vigil wanted line-wise or character-wise
      > > blocks, if you want it in line-wise, you can just use the ex command
      > >
      > > :/this/,/find/y e
      > >
      > > which will yank those lines into register "e". If you want
      > > character-wise, Tony and Yakov's solutions are more what you'll need
      > > (though more convoluted than the straight-forward line-wise ex command
      > > above)
      > >
      > > -tim
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      >
      > He said "starting at 'this' and all after it on the same line until
      > 'find'". Both words were on the same line, so characterwise and
      > blockwise (but not linewise) are equivalent.
      >
      > One thing I forgot was that he wanted it to work regardless of whether
      > the search for "this" was forward or backward. This can be easily taken
      > care of:
      >
      > exe "normal \<Home>" . '/\<this\>' . "\r" . '/\<find\>' . "\r" . 'e"ey'
      >
      > still untested, and still all on one line.
      >

      You can also use one of the following commands:

      let @e = matchstr(getline('.'), '\<this\>.\{-}\<find\>')
      let @e = matchstr(getline('.'), '\<this\>\(\(this\)\@!\).\{-}\<find\>')

      - Yegappan
    • Charles E. Campbell, Jr.
      As frequently happens, there s often multiple ways to do things in vim. Here s another: / / ey/ / (its a one liner, starting from normal mode)
      Message 2 of 14 , Feb 1, 2006
      • 0 Attachment
        As frequently happens, there's often multiple ways to do things in vim.
        Here's another:

        /\<this\>/"ey/\<find\>/

        (its a one liner, starting from normal mode)

        Regards,
        Chip Campbell
      • Charles E. Campbell, Jr.
        ... Whoops; please try / / ey/ zs/ instead (to get the find included). Regards, Chip Campbell
        Message 3 of 14 , Feb 1, 2006
        • 0 Attachment
          Charles E. Campbell, Jr. wrote:

          > As frequently happens, there's often multiple ways to do things in
          > vim. Here's another:
          >
          > /\<this\>/"ey/\<find\>/
          >
          > (its a one liner, starting from normal mode)
          >
          > Regards,
          > Chip Campbell
          >
          Whoops; please try

          /\<this\>/"ey/\<find\>\zs/

          instead (to get the "find" included).

          Regards,
          Chip Campbell
        • Tim Chase
          ... Or you can use the search modifiers / /e+ instead of the zs (one-third fewer characters, lower in trans-fats, and tastes great! :*) You ll also
          Message 4 of 14 , Feb 1, 2006
          • 0 Attachment
            > Whoops; please try
            >
            > /\<this\>/"ey/\<find\>\zs/
            >
            > instead (to get the "find" included).

            Or you can use the search modifiers

            /\<find\>/e+

            instead of the "\zs" (one-third fewer characters, lower in
            trans-fats, and tastes great! :*)

            You'll also want to hit <enter> after entering the search for
            /\<this\>/ (which can be done instead of the closing slash) which
            would make it

            /\<this\><cr>"ey/\<find\>/e+

            (where the <cr> is either literal in a mapping, or the actual
            <enter> key if typed live)

            -tim
          • Vigil
            ... Maybe I have some weird setting but none of those methods work. The immediate above one says the pattern is not found: E486: Pattern not found:
            Message 5 of 14 , Feb 2, 2006
            • 0 Attachment
              On Wed, 1 Feb 2006, Tim Chase wrote:

              >> /\<this\>/"ey/\<find\>\zs/
              >>
              >
              > /\<this\><cr>"ey/\<find\>/e+

              Maybe I have some weird setting but none of those methods work. The immediate
              above one says the pattern is not found:

              E486: Pattern not found: \<this\><cr>"ey

              --

              .
            • A. J. Mechelynck
              ... That s normal, input this way is interpreted as four characters, not one control code. Did you try my pattern? (all on one line) ... Best regards,
              Message 6 of 14 , Feb 2, 2006
              • 0 Attachment
                Vigil wrote:
                > On Wed, 1 Feb 2006, Tim Chase wrote:
                >
                >>> /\<this\>/"ey/\<find\>\zs/
                >>>
                >>
                >> /\<this\><cr>"ey/\<find\>/e+
                >
                > Maybe I have some weird setting but none of those methods work. The
                > immediate above one says the pattern is not found:
                >
                > E486: Pattern not found: \<this\><cr>"ey
                >

                That's normal, <cr> input this way is interpreted as four characters,
                not one control code. Did you try my pattern? (all on one line)

                :exe "normal \<Home>" . '/\<this\>' . "\r" . 'v/\<find\>' . "\r" . 'e"ey'


                Best regards,
                Tony.
              • Charles E. Campbell, Jr.
                ... Hmm, the was meant to be a carriage return, not the four characters . The / is intended to get your cursor on the word this .
                Message 7 of 14 , Feb 2, 2006
                • 0 Attachment
                  Vigil wrote:

                  > On Wed, 1 Feb 2006, Tim Chase wrote:
                  >
                  >>> /\<this\>/"ey/\<find\>\zs/
                  >>>
                  >>
                  >> /\<this\><cr>"ey/\<find\>/e+
                  >
                  >
                  > Maybe I have some weird setting but none of those methods work. The
                  > immediate above one says the pattern is not found:
                  >
                  > E486: Pattern not found: \<this\><cr>"ey
                  >
                  Hmm, the <cr> was meant to be a carriage return, not the four characters
                  < c r > .
                  The /\<this\> is intended to get your cursor on the word "this".

                  Regards,
                  Chip Campbell
                • Vigil
                  ... It is too long O:) -- .
                  Message 8 of 14 , Feb 3, 2006
                  • 0 Attachment
                    On Thu, 2 Feb 2006, A. J. Mechelynck wrote:

                    > That's normal, <cr> input this way is interpreted as four characters,
                    > not one control code. Did you try my pattern? (all on one line)
                    >
                    > :exe "normal \<Home>" . '/\<this\>' . "\r" . 'v/\<find\>' . "\r" . 'e"ey'

                    It is too long O:)

                    --

                    .
                  Your message has been successfully submitted and would be delivered to recipients shortly.