Compare External Files in Eclipse

Eclipse is very workspace centric: it only knows and deals with files in the workspace. So it is easy to compare and merge files present in the workspace: I select both files/folders and compare them with each other:

Compare with Each Other

Compare with Each Other

But what if the files and folders are NOT in the workspace?

Hidden Option to Compare External Files

As outlined in this post, it needs a special plugin to search for files outside the Eclipse workspace. And doing a file or folder compare outside of the workspace requires a trick as shown in this post.

Thanks to a tip from John there is another (hidden) way in Eclipse to compare external files 🙂

Keyboard Shortcut

The trick is described in this article and requires a keyboard shortcut assigned.

Select the menu Window > Preferences > General > Keys and assign a shortcut key for ‘Compare with Other Resource‘:

Compare With Other Resource Key Binding

Compare With Other Resource Key Binding

(I’m using Ctrl+Shift+Home above).

Comparing

To compare, I have first to select a file, folder or project, then I press my shortcut. Then the following dialog shows up (with the selection as default):

Select resource to compare

Select resource to compare

💡 If the dialog does not show up, then I probably have not selected a file or folder in the Eclipse project view.

Now I can select the external files or folders to compare with:

Selected External Files

Selected External Files

With this, I can now compare and merge my files and folders with the Eclipse Compare view:

Compare View in Eclipse

Compare View in Eclipse

💡 I can select two files/folders and then press the shortcut, and it will populate the search dialog values.

Drag & Drop

That compare dialog has a nice feature: I can drag&drop files and folders too:

C:\ProgramData\Processor Expert\CWMCU_PE5_00\Examples\FRDM-KL25Z\FRDM-KL25Z_RNet\Sources

C:\ProgramData\Processor Expert\CWMCU_PE5_00\Examples\FRDM-KL25Z\FRDM-KL25Z_RNet\Sources

Summary

With ‘Compare with Other Resource‘ I have a way to compare files/folders, and I’m not limited to the workspace files. The only disadvantage is that I need to assign a shortcut for it first. Beside of that: yet another hidden treasure in Eclipse :mrgreen:.

Happy Comparing 🙂

Advertisements

6 thoughts on “Compare External Files in Eclipse

  1. Good tip, thanks! Up to now I used another trick (for single files): opend the file in eclipse (either by drag’n’drop or double-clicking on a file in Remote System Explorer view), and used the local menu item “Compare with” / “Opened editor” and selected the file from the list of opened files. Right now I see there is another option too (in Keipler): “Compare with” / “External file”.

    Another fancy trick is comparing to the clipboard contents (“Compare with” / “Clipboard”). I used to use it a lot, after my colleage has re-written complete modules causing the order and location of functions to be completely different, a situation an average compare tool cannot handle.

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s