Sunday, May 16, 2010

Re: Search using the Highlighted text as pattern

> Based on John's suggested link, I modified * for search forward.
>
> ""-----=-------=-------=-------=-------=-------=-------=-------=
> " multi line search selection literal (vi6.2 ok) :help c_<C-R>
> vmap * y/\V<C-R><C-R>=substitute(escape(@",'\/'),'\n','\
> \n','g')<cr><cr>

This is very cool!

However, when you use the mouse to highlight some text and then press
*, you are left in "-- SELECT --" mode. This means when you type "n"
for the next match, instead your highlighted text is replaced with a
literal letter "n". Boo!

I did try this mapping but it doesn't fix the problem:
:vmap * y/\V<C-R><C-R>=substitute(escape(@",'\/'),'\n','\
\n','g')<cr><cr>:vi!<cr>

If you leave the final <cr> off my mapping, then it does leave you
with a :vi! in the Ex command line, and you can hit enter to leave Ex
mode.

Anyone have any pointers what I'm doing wrong? I want to end up in
Normal mode after highlighting text with a mouse and using the *
mapping above.

Cheers,
Gareth

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: