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

Re: searching using motions

Expand Messages
  • Gary Johnson
    ... Here is yet another mapping that does that (contributed to this list by someone else several months ago): Search for the highlighted text. vmap g/
    Message 1 of 6 , May 1, 2002
    • 0 Attachment
      On Wed, May 01, 2002 at 10:20:22AM -0700, Tim O. Gunter wrote:
      > i would like to be able to search for a string in using motions to select
      > the string from the cursors current position. for example i would like
      > to be able to type something like "*3w<cr>" to highlight the next three
      > words and search for all occurrences of them in the current buffer.
      > is there anyway to do this? the "*" and "#" commands dont support motions,
      > is there any other command that does?

      Here is yet another mapping that does that (contributed to this list by
      someone else several months ago):

      " Search for the highlighted text.
      vmap g/ y/<C-R>"<CR>

      Gary

      --
      Gary Johnson | Agilent Technologies
      garyjohn@... | Spokane, Washington, USA
    • Thomas S. Urban
      ... Note that both this and the function I posted earlier will not work right when certain special characters are present in the text that will be searched
      Message 2 of 6 , May 2, 2002
      • 0 Attachment
        On Wed, May 01, 2002 at 23:21:02 -0700, Gary Johnson sent 0.7K bytes:
        > On Wed, May 01, 2002 at 10:20:22AM -0700, Tim O. Gunter wrote:
        > > i would like to be able to search for a string in using motions to select
        > > the string from the cursors current position. for example i would like
        > > to be able to type something like "*3w<cr>" to highlight the next three
        > > words and search for all occurrences of them in the current buffer.
        > > is there anyway to do this? the "*" and "#" commands dont support motions,
        > > is there any other command that does?
        >
        > Here is yet another mapping that does that (contributed to this list by
        > someone else several months ago):
        >
        > " Search for the highlighted text.
        > vmap g/ y/<C-R>"<CR>

        Note that both this and the function I posted earlier will not work
        right when certain special characters are present in the text that will
        be searched for. Those characters should be escaped. Here is what I
        have in my vimrc for searching for visually selected text:

        vnoremap ;sn "sy:let @s = escape (@s, '^~/.*[]')<CR>/<C-R>s<CR>


        Scott

        --
        Blessed is he who expects nothing, for he shall never be disappointed.
        -- Alexander Pope
      Your message has been successfully submitted and would be delivered to recipients shortly.