Platinum Partner
eclipse,tips and tricks,tools & methods

Eclipse Local History & Quick Diff

I worked long hours on my project, and it was working well. But after a series of edits, somehow the application was not working the way it should. What did I change to break my code? Usually I smile, because I have things in a version control system. But: not this time (I should know better!). Luckily there are some ways to find out what has been changed: with the Local History and Quick Diff.

Local History

Even if not using a version control system, Eclipse has a local history built-in. To compare and diff with the history, I use the menu

Compare with Local History

Compare with Local History

This opens the History View which offers compare and merge (see Compare and Merge in Eclipse):

History View

History View

The number of entries (and size) of the local history is configured in the following workspace setting (menu Window > Preferences > General > Workspace > Local History):

Local History Preferences

Local History Preferences

Note: keeping a long history might slow down Eclipse, especially at workspace closure time (see CodeWarrior Tool Tip #3). So better not to keep too much of history.

Quick Diff

The Local History is nice, but there is even a faster way: Quick Diff!

Quick Diff can be enabled (if not already done) in the workspace settings (menu Window > Preferences > General > Editors > Text Editors > Quick Diff):

Quick Diff Preferences

Quick Diff Preferences

In the settings I can change the colors, and as well what to use as reference ((Version on Disk, Latest CVS Version  or Pristine SVN Copy).

Note: There seems to be a problem (oversight?) in Eclipse (at least 3.6) with using ‘Version on Disk’: With saving a file the Quick Diff markers are gone too :-( . But it works as expected with the SVN settings. Another good reason to use SVN :-) .

There is a general option to enable Quick Diff, and I have enabled as well the ‘Show differences in overview ruler’.

What it does: it shows the differences in the left editor area (where usually the line numbers are):

Quick Diff Color Marker

Quick Diff Color Marker

The colors are as configured in the Quick Diff preferences shown earlier.

If I move the mouse over the marker, a pop-up window shows up:

Quick Diff Mouse Over

Quick Diff Mouse Over

The first character in the pop up indicates what has changed:

  • >: changed line
  • +: inserted line
  • -: deleted line

Note the ‘Press ‘F2′ for focus’: That way I copy and restore my earlier version. Quick is simple and fast  and gives me an immediate access to the earlier version.

Happy Quick Diffing :-)

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ }}
{{ parent.authors[0].realName ||}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks