In my case, I have two files file1 and file2. Using vimdiff, I want to merge the changes as follows:
You can just switch between the windows and copy and paste to resolve the differences, as @David W. suggests in his answer, but Vim also has dedicated :diffput
and :diffget
commands to simplify this. With these (or the corresponding normal mode do
and dp
commands), you don't have to switch between windows, and the range defaults to the current change.
If you need to add instead of overwrite with the other buffer's differences (which is a rather unusual case in a classic two-way diff), you still have to yank the original lines and put them after the :diffget
.
After you're done in one place, you can use the ]c
, [c
commands to jump to the next difference.