Yup that was useful, but I am stuck at the next step of my quest.
I visually select the search pattern using "//<cr>v//e<cr>", then yank it to
a register - say 0 ("0yy).
After that, I want to evaluate the yanked text to delete the highlighted part
if it meets a condition, as in ->
:if (!(@0=~"set_reg")) | exe "normal //" | exe "normal v" | exe "normal //e"
| exe "normal d"| endif
But here instead visually selecting and deleting the match this command gets
stuck at - exe "normal v"; i.e. it gets into the visual mode but fails to do
the next set of commands.
What should it be instead of - exe "normal //e" ?
Regards,
Sibin
-----Original Message-----
From: Tim Chase [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 08, 2007 10:40 PM
To: Sibin P. Thomas
Cc: Vim Mailing List
Subject: Re: how do u visually select a search pattern?
> I would like to search for the pattern "para\_.\{-}variable".
> When I am on the highlighted selections (3 pairs of lines in
> this case), I would like to yank the highlighted portion to a
> register (for evaluation etc).
Well, it's not quite what you describe, but it's like the "n/N"
functionality for finding the *next* (or previous) match and
highlighting it:
:nnoremap <f4> //<cr>v//e<cr>
:nnoremap <f5> ??e<cr>v??<cr>
It might also be handy to have some visual-mode mappings such as
:vmap <f4> <esc><f4>
:vmap <f5> <esc><f5>
So you can continue forward/backward in your searching.
Getting it to highlight the results immediatedly after searching
is a considerably more difficult stunt. Doable, but not without
a number of crazy stunts and mindbendingly opaque mappings. At
least from my determination of matters. YMMV ;)
HTH,
-tim
DISCLAIMER:
This message (including attachment if any) is confidential and may be
privileged. Before opening attachments please check them for viruses and
defects. MindTree Consulting Limited (MindTree) will not be responsible for any
viruses or defects or any forwarded attachments emanating either from within
MindTree or outside. If you have received this message by mistake please notify
the sender by return e-mail and delete this message from your system. Any
unauthorized use or dissemination of this message in whole or in part is
strictly prohibited. Please note that e-mails are susceptible to change and
MindTree shall not be liable for any improper, untimely or incomplete
transmission.