Re: searching using motions
- 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:Note that both this and the function I posted earlier will not work
> > 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>
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>
Blessed is he who expects nothing, for he shall never be disappointed.
-- Alexander Pope