> Is there a way of replacing a term yanked in my buffer?
> Lets say I yanked this string "yada yada yada" to the 0 register (default).
> How can I use the content of register 0 to search or replace?
> 
> Would be nice if I could do this:
> :%s/"0//gc
> 
> Any tips?
> Is that possible?

Yes, you want the control-R prefix:

   :%s/<c-r>0//gc

as described in

   :help i_ctrl-r

However, it only dumps it in as if you typed it, so if you have 
metachars such as ".", "/", "*", etc, you'd have to then go back 
and escape them.  For fixed text/space strings, it tends to work 
well, but if you have multiline or extra punctuation characters, 
you have to jump through some hoops.  If it's a big problem, you 
can use something like

   :%s/<c-r>=escape(@0, '.^$/\\')<cr>//gc

using the expression-register as your insertion (adjusting the 
2nd parameter of the escape() call for whatever metacharacters 
you'd use)

This more complex expression can be mapped something like

   :cnoremap <f4> <c-r>=escape(@0, '.^$/\\'))<cr>

so you can just type

   :%s/<f4>//gc

Hope this helps give you some ideas towards what you want to do.

-tim




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to