Monday, February 21, 2011

Re: Copy/delete/paste strategy?

On Mon, 21 Feb 2011, David Kahn wrote:

> Relatively new to vim. I know there are other ways to do this specific
> task such as search/replace but I want to understand how to repeatedly
> paste some text but also overwrite a certain character, in the case I
> want to do it manually. This has brought me to need to understand if
> there is a sort of clipboard/yank history.
>
> For example, I have yanked this text:
>
>   .truncate(
>
> I want to replace the comma ',' in the lines below with my yanked text
> in each line:
>
>   word,12)
>   word2,12)
>   word3,12)
>
> So what I do is move in regular mode to the first comma and press 'x'
> to remove the comma, and then press 'p'... however instead of getting
> my yanked text, I get the text now under the cursor, in this case '1'.
> So how do I handle a yank > delete > put operation, and multiple
> times?

Not quite sure what's happening based on your description, but two
things I find helpful with yank/put sequences:

1. :reg - provides a list of the numbered and named registers

"xp - pastes the contents of register 'x'.


2. If you yank something between (sounds in the example like the 'x'
command yanked the '1'?), but want a recently-yanked thing, this
sequence is useful:

"1p - pastes whatever's in the first register
u - if it's wrong, undo
. - repeat last action, with "smart" feature of incrementing a
numbered register.

So, e.g.
p - oops, pasted wrong thing
"1p - hmm, still wrong
.u.u. - repeat until right

For fuller explanation, see:
:help redo-register

--
Best,
Ben

--
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: