On Wed, 26 Apr 2006, Halim, Salman wrote:
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:
[snip]
How about another mapping that does something like:
:let @/=substitute(@/, '\d\+', '\\d\\+', 'g')
[snip]
Thanks. I think I'll include number generalization in my "extreme"
version of <kMultiply> ;) Seems useful enough. It now looks like:
(one line)
vnoremap <silent><kMultiply>
y/\V<C-r>=substitute(substitute(escape(@@,'/\'),'\_s\+','\\_s\\+','ge'),'\d\+','\\d\\+','ge')<CR><CR><C-o>
--
Gerald