Lets say that i have this text:
$test = 'lorem'; $test2= 'ipsum';
and I want to copy lorem and paste into ipsum.
I tried to do yi'
on lorem and then went on ipsum and did ci'
but that replaced my pastebin with ipsum. and my previous copy was lost.
After you do
ci'
on impsum your lorem is in register"0
. So, you can doci'^R0
(^R
meansCtrl+r
) and paste your lorem in place of ipsum.See
:help quote_number
for more info on numbered registers.Why don't you yank into a named buffer, using
"ayi'
, then delete and paste withd'i"aP
?Words here to stop Markdown treating the code that follows as plain text.
The first text searches for 'lorem'; the next deletes the word into the buffer named 'a', leaving a pair of empty quotes behind in the text. The next search finds 'ipsum'; the
"aP
pulls the buffer named 'a' in before the word ipsum; the"bdw
deletes the word into the buffer named 'b', leaving 'lorem' behind. The double back-tick goes back to the place the last search came from - the empty quotes; and"bp
pulls the named buffer after the first quote.You can also omit the
"a
and"b
, but this way, the values are in the named buffers"a
and"b
and can be copied again, and again, and again until you don't need the values any more.vi'y
on loremvi'p
on ipsumgvy
to copy back lorem to register for possible macro withvi'p
(
qa
-gvy
-j
-vi'p
-q
-@a
-@@
-@@
...)You want to use
y
to copy a selection andp
to paste.Here is a good list to keep handy.
I usually go to the sed command.
%
means do this for every lines
means sed, or search and replaceg
at the end means replace everyipsum
withlorem
; if you omit this, it only replaces the first.