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 lor
I'm not sure what do you want exactly.
You have this on two lines:
$test = 'lorem';
$test2= 'ipsum';
If you go to l and yw, it yanks lorem, then go to i of ipsum, and cw, and p and it will replace ipsum with lorem. You will still have both lorem and ipsum in the registers.
You can get the contents of those registers with :reg
If you want to paste something from them then "*p, or ":p, or "0p (you'll see it when you type :reg)
vi'y on lorem
vi'p on ipsum
gvy to copy back lorem to register for possible macro with vi'p
(qa - gvy - j - vi'p - q - @a - @@ - @@ ...)
I usually go to the sed command.
:%s/ipsum/lorem/g
% means do this for every lines means sed, or search and replaceg at the end means replace every ipsum with lorem; if you omit this, it only replaces the first.Go to the l of lorem, ye (yank to end of word). Go to the i of ipsum, "_de (delete to end of word, putting the deleted text in the black hole register. P (paste register before cursor).
Altogether: yej"_deP