3

When viewing a diff of two files in Vim, you can put changes from the source file to the destination file by pressing d then p, or by running :diffput. However, this doesn't work if the change is a deleted line.

For example, let's look at the contents of the file one.txt:

a
b
c

And the contents of the file two.txt:

a
c

If I open the two files in diff mode (vimdiff one.txt two.txt), and I have my cursor on the file two.txt, how do I push the change (that is, the deleted line) from two.txt to one.txt? The only way to do it seems to be to change the focus to the other window one.txt and then run do, but that is a lot of keystrokes, especially if you have multiple windows open.

1 Answer 1

4

Put the cursor beneath the deleted block, i.e., in your case on line c in the file two.txt, and press dp.

Your Answer

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

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