Drawing Hands by M.C. Escher (1948)

Jeff Mesnil


Using Eclipse to compare two files

On October 7th, 2004 in eclipse

I often need to compare two files to see their differences.
The UNIX geek in me is using diff --side-by-side for that. But sometimes I want something more fancier with bright colors and easier to scroll.

Eclipse provides a handy feature to compare two unrelated files (e.g. not two CVS revisions of the same file) but it’s quite difficult to find it first.
To compare two files in Eclipse, select both files (Control click them) and in the contextual menu (right button), chose Compare With > Each Other. Et voila! you got a nicer diff than its CLI counterpart.

10 Responses to “Using Eclipse to compare two files”

  1. Anonymous Says:

    You is da man Jeff. That is exactly what I was looking for.

    Please post any other Eclipse tips you have !

    Zafar, An-Eclipse-Beginner

  2. Anonymous Says:

    Zafar,

    Are you the anonomous person who left the message saying thanks about finding the eclipse thingie.

    Anon…

  3. Zoli Says:

    Thx man! I almost started manually merging files together, but you saved me couple of minutes!

  4. Brian Mauter Says:

    Thanks a bunch! That was exactly what I was looking for!!!

    -Brian

  5. Ken Says:

    Hey do you know of a way to generate a diff file while comparing two unrelated files? I can generate a diff file while comparing two revisions of the same file but I would like to auto-merge changes from one file into another. Thanks.

  6. jmesnil Says:

    Ken, I don’t know how to generate a diff file from Eclipse using the “Compare with each other” command.
    However, you can still use the Compare editor to copy the changes from one file to another using the buttons of the Compare editor.

  7. Adam Says:

    Thanks Man, I’ve been looking for a diff plugin for ages but it looks like it was right there in front of me the whole time !

  8. Neil Says:

    You can also use this to compare two directories!!! Then you can drill down into each file to see the difference. Just select both files in Navigator right-click one and then compare

  9. Ram Says:

    Hello,

    How to programatically do this in Eclipse? I want to compare 2 files and assert whether
    they are same or not?

    Literally, the code behind this comparison editor in eclipse i guess.

    Thanks,
    Rama

  10. Viacheslav Garmash Says:

    Today I’ve tried to compare 2 files with size about 300K each. Eclipse’ve ate all free memory in my laptop (1.5 G RAM), hang itself for 3 minutes and only after that showed compare editor… So as I can see implementation of “compare to each other” very staight-forward and works very bad.

    Any way thanks for the tip! For people who don’t have Araxi Merge this solution better than nothing.