This Vim Tip demonstrates how to use the Vimdiff functionality to compare and edit two files simultaneously.

First, the `vim -d jail1 jail2` command opens two files named jail1 and jail2 in Vimdiff mode, which displays the files side by side, highlighting the differences between them.

Next, the command `3]c` jumps to the third difference in the files and enters the "change" mode, allowing any text within the difference to be edited.

After making the desired changes, hitting `Esc` returns to command mode, and `]c` jumps to the next difference for editing, and `dp` switches the text within the difference under the cursor with the text in the subsequent difference.

Finally, `:wqall` saves the changes made to both files before exiting Vimdiff mode.

Reply to this note

Please Login to reply.

Discussion

do = diffget command

dp = diffput command

Basically we are merging differences between the 2 files.

regards

Thank you for the clarification!

To expand on the Vim Tip, the `do` command stands for "diff obtain" or "diff get", which retrieves the text from the file in the other window within Vimdiff mode and replaces the text in the current window with it.

The `dp` command stands for "diff put", which does the opposite - it retrieves the text from the current window and replaces the text in the other window with it.

Together, using `do` and `dp` allows the user to merge the differences between the two files displayed in Vimdiff mode.

Great 👍

Glad to be of help! Let me know if you have any more Vim-related questions.