3

A common function I do in textmate or any other editor is copy some text and then paste it over some other text, for example: https://gyazo.com/fcef05504e83b608b583af085f92ecd2.

enter image description here

enter image description here

enter image description here

Currently to copy a value I do something like yiw, however if I delete the next work, diw, it would also yank in that text, which I want to overwrite. What would be the best way to do this process, which I feel like I do all the time?

2
  • Does this answer your question? Performing certain operations without clearing register
    – Biggybi
    May 4, 2020 at 2:44
  • @Biggybi I don't think that one is a great duplicate for this one, since the way it's phrased doesn't lead to the p in Visual mode solution same as this one does... It's related and some solutions from that one will also work for this one, but I still think this one has a nice specific solution, so worth keeping it open.
    – filbranden
    May 4, 2020 at 5:03

1 Answer 1

4

The easiest is probably to select the word to be replaced in visual mode instead of deleting it:

viwp

If you don’t like that, an alternative is to delete without clobbering your yanked text by deleting into the black hole register:

"_diwp

Another alternative is to delete normally, but then paste from the yank register, which isn’t overwritten by your delete:

diw"0p

See :help registers for more details on the above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.