> -----Original Message-----
> From: Peng Yu [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, March 10, 2007 10:38 PM
> To: vim@vim.org
> Subject: How to paste without replace the content in buffer
> 
> Hi,
> 
> Suppose I want to replace "string1" with "string2" in a file from vim.
> 
> 1. Highlight "string1" (in visual mode) and then type "y".
> 2. Highlight "string2" (in visual mode) and then type "p".
> 
> However, the problem with the above procedure is that 
> "string2", instead of "string1", is in buffer. That is if I 
> highlight "string3"
> and then type "p", "string3" will be replaced with "string2" 
> instead of "string1".
> 
> I'm wondering if there is any way to avoid change the content 
> in the buffer?

You might want to consider using one of my plugins:

YankRing.vim : Maintains a history of previous yanks and deletes 
http://www.vim.org/scripts/script.php?script_id=1234

Vim already maintains a list of numbered registers containing the last 9
deletes.  These previous deletes can be referenced using [register]p, so
"1p will paste the last delete, "2p the 2nd last delete.  For more
information see |quote_number|.

Vim does not provide any mechanism to reference previous yanked text.  In
Emacs this feature is called the "kill ring".

The yankring plugin allows the user to configure the number of yanked and
deleted text.  A split window can be used to choose which element(s) from
the
yankring you wish to paste.  Alternately after text has been pasted (using
p),
it can be replaced with a previous value from the yankring with a single key
stroke.

A tutorial is included to take you through the various features of the
plugin.  After you have installed the plugin just run:
     :h yankring.txt
     :h yankring-tutorial

The yankring can be interacted with in two ways:  a GUI or via maps. 
...



More details and features to go with it.  Have a look at the webpage for
more details.

HTH,
Dave
 

Reply via email to