vim copy and replace text

前端 未结 10 2229
名媛妹妹
名媛妹妹 2021-02-14 18:02

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

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 18:49

    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)

提交回复
热议问题