Merge changes using vimdiff

后端 未结 3 637
礼貌的吻别
礼貌的吻别 2021-01-30 01:32

In my case, I have two files file1 and file2. Using vimdiff, I want to merge the changes as follows:

  1. In first difference, place line from file1 above line from fi
3条回答
  •  攒了一身酷
    2021-01-30 02:06

    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.

提交回复
热议问题