views:

1157

answers:

3

vimdiff helps in showing the diff of two files graphically and allows us to pick the changes from left to right/right to left.
The files I am dealing with are huge files and most of the differences vimdiff reports can be auto-merged except a few.As it takes lot of time to go diff by diff in vimdiff and take the action.

I would like to know if there is an option available in vimdiff that automerges the differences in left and right files as long as there is no ambiguity and leaving the conflicted resolutions similar to the tools svn merge and cvs merge tools does?

A: 

Looks like vimdiff does not allow that. Man page says
"vimdiff - edit two or three versions of a file with Vim and show differences"

But you can have a look at Kdiff3 which lets you compare and merge.

codaddict
+1  A: 

If you use no version control, you can try diff and patch this way:

  1. Before changing your file (say, file.txt), make a backup of the original version (file.orig).
  2. When changed are made, make a patch-file: diff file.orig file.txt >patch.txt
  3. Get a file which you want to merge changes to (say, file2.txt).
  4. Use patch: patch file2.txt patch.txt

Changes will be merged, conflicted rows will be placed in a separate file.

egorius
+1  A: 

Its not possible to auto-merge the changes in two files unless we have a base copy where these two files branched and changes done separately. If an item is on one side and not on the other,it can't judge whether this item was newly added or an existing item was deleted. As there is a base copy exists while merging files in a repository, cvs merge,svn merge can auto-merge the changes.

Naga Kiran