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:
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‘:
(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):
💡 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:
With this, I can now compare and merge my files and folders with the Eclipse Compare view:
💡 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:
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 🙂
Reblogged this on Sutoprise Avenue, A SutoCom Source.
LikeLike
I think you wish to try Beyond compare. Cooler, it also has plugin for Eclipse 🙂
LikeLike
thanks for that hint. Yes, Beyond Compare looks really nice too.
LikeLike
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.
LikeLike
Oh wow! I was not aware of that ‘compare with clipboard’ thing! Thanks for sharing!
LikeLike
Hey folk you can do compare with beyond compare tool in the eclipse work space itself
here you go http://beyondcvs.sourceforge.net/
LikeLike