Monday, February 21, 2011

Re: Copy/delete/paste strategy?

Reply to message «Copy/delete/paste strategy?»,
sent 19:41:29 21 February 2011, Monday
by David Kahn:

> 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?
You can either specify blackhole register when you do removal or specify yank
register when you do paste. But in order to be able to repeat your action with
dot I suggest one of the following: blackhole variant: «"_s<C-r>"<Esc>», yank
register variant: «s<C-r>0<Esc>». Alternatives (not repetive by a dot): «v"0p»
(pasting in visual mode replaces selected area and single «v» selects the single
character under cursor if you have not passed any motions yet), with «x» and
«p»: «"_xp» or «x"0p». Better suggestion: use «vp» with the following mapping:

vnoremap <expr> p "\"_c\<C-r>\<C-r>".v:register."\e"

(can be typed fast and is repetive by dot).

Original message:
> 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?

No comments: