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

RE: invoking yanked register into colon command

Expand Messages
  • Gene Kwiecinski
    ... name) ? ... Me, I go to whatever I m looking for, hit v , then use normal motion commands (eg, 3e ) to highlight the text in question, instead of using
    Message 1 of 8 , Apr 2, 2007
      >after having read the user-manual. For example, I do often want to
      >replace a name in the text with another. What I used to do is
      >selecting it with mouse and type
      >:%s/<ctrl-ins>/newname/gc
      >Is there a way to do this with the mouse (and without retyping the
      name) ?
      >What I want is maybe something like 'invoking a yanked register in my
      >colon command'

      Me, I go to whatever I'm looking for, hit 'v', then use normal motion
      commands (eg, "3e") to highlight the text in question, instead of using
      the moose.

      If a single word, '*' will automagically highlight and search for the
      word under the cursor.

      From there, once you highlighted the exact pattern you want, can just
      use

      :%s//newname/gc

      as it remembers what you just looked for. No need to reinsert it for
      the 's' command.
    • John Little
      ... And with vnoremap * y:exe norm! / . escape(@@, /*. [$^~ ) . r in your .vimrc, it works for more than a single word, any stuff up to a line s
      Message 2 of 8 , Apr 3, 2007
        Gene Kwiecinski wrote:

        > Me, I go to whatever I'm looking for, hit 'v', then use normal motion
        > commands (eg, "3e") to highlight the text in question, instead of using
        > the mouse.
        >
        > If a single word, '*' will automagically highlight and search for the
        > word under the cursor.

        And with

        vnoremap * y:exe 'norm! /' . escape(@@, '/*.\[$^~') . "\r"<cr>

        in your .vimrc, it works for more than a single word, any stuff up to a
        line's worth.

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