> > I use the extreme version:
> >
> > vnoremap <silent> * "yy:let @/='\(' . substitute( escape( @y, 
> > '$*^[]~\/.' ), '\_s\+', '\\_s\\+', 'g' ) . '\)'<cr>:set hls<cr>
> >
> > This escapes a lot of stuff, including replacing any 
> whitespace with a 
> > generic expression that includes newlines.  I like it 
> because if you 
> > highlight 'a b' (without the quotes) and hit *, it will subsequently
> > also match 'a             b', 'a\nb' (where the \n 
> indicates that the a
> > and b are on different lines).  I got the idea from a previous 
> > discussion on this list (might well have been Gerald posting his 
> > mappings earlier).
> 
> Good idea :) I'll adopt it for my <kMultiply>. Question, do 
> you think it would be useful to extend this to numbers too? 
> For example, visual matching "123" results in "\d\+"?

I thought about doing substitutions to non-whitespace characters
(numbers with \d\+ and letters/underscores with \w\+) but it seemed to
match too many things.  Admittedly, I will occasionally have something
like this:

Word1 generalStuff Word2

Where 'generalStuff' could be any word (I don't care about it, as long
as it's flanked by Word1 and Word2); when that happens, I do end up
manually modifying the search after the *, but that happens infrequently
enough (whether with numbers or digits) that it doesn't inconvenience me
that much.

How about another mapping that does something like:

:let @/=substitute(@/, '\d\+', '\\d\\+', 'g')

That way, when you decide you really want generic numbers, you can just
hit the mapping after the * to make it happen.

Regards,

Salman.

Reply via email to