On 2007-04-06, [EMAIL PROTECTED] wrote:
> Hi,
> 
>  is there a way to do this more effectively?
> 
>  I often get in the situation of yanking a word
>  into the buffer, search another word I want to
>  replace with the contents of the buffer, delete
>  the found word and paste the contents of the buffer
>  at the place of the previously found word.
> 
>  Despite the fact, that -- without the yank-ring
>  script -- you have to keep an eye on what is
>  in what buffer, it would be more effective
>  if one could do the following:
>   
>  yw                    "yank replacement word
>  /word                 "find word ("word") to be replaced
>  cw                    "change word under cursor with that in buffer
>         
>  I know, that "cw" is another command, which is "wrong" in 
>  this case...I only needed a name for what I want to do and
>  cw keeps track of the length of the replaced word and the
>  replacement.
> 
>  Thank you very much for any helpful hint :)   !

Actually, "cw" isn't wrong, it's just incomplete.  Yanked but not 
deleted text goes automatically into the 0 (zero, not oh) register 
unless you specified some other register.  So "yw" yanks the 
replacement word into both the unnamed register and register 0.  
Then all you have to do is specify register 0 as the source of the 
replacement text when you type "cw" by following "cw" with "^R0" 
where by ^R I means Ctrl-R.

You can read more about these registers under

    :help registers

sections 1. and 2., and about using Ctrl-R under

    :help i_CTRL-R

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Mobile Broadband Division
                             | Spokane, Washington, USA

Reply via email to