Vimdiff as a merge tool

vimdiff helps display the diff of two files graphically and allows us to select changes from left to right / right to left.
The files I'm dealing with are huge files and most of the differences. Vimdiff reports can be automatically combined, with the exception of a few. Since it takes a long time to split diff into vimdiff and take action.

I would like to know if there is an option in vimdiff that simplifies the differences in the left and right files, if there is no ambiguity, and leaving conflicting permissions similar to the svn merge and cvs merge tools tools does?

+4
source share
3 answers

It is not possible to automatically merge changes in two files unless we have a base copy where these two files are forked and the changes are done separately. If an item is on one side and not on the other, it cannot judge whether the item was added again or if the existing item was deleted. Since there is a base copy when merging files in the repository, cvs merge, svn merge can automatically merge the changes.

+4
source

If you are not using a version control, you can try breaking up and planning this way:

  • Before modifying the file (say file.txt), back up the original version (file.orig).
  • When changing, make a patch file: diff file.orig file.txt >patch.txt
  • Get the file you want to merge, modify (say file2.txt).
  • Use patch: patch file2.txt patch.txt

Changes will be merged, conflicting lines will be placed in a separate file.

+3
source

Vimdiff doesn't seem to allow this. The man page says
"vimdiff - edit two or three versions of a file with Vim and show the differences"

But you can see Kdiff3 , which allows you to compare and combine.

0
source

All Articles