Have you ever been editing your code, and sometime down the road -- maybe 5 minutes, maybe 2 hours, maybe after lunch -- you break something. It used to work, and now it doesn't. You're thinking, "what change, of all the beautiful edits I've made, broke my fortress of code?" Being an experienced Eclipse user, you smile and say to yourself, "I know, I'll compare to my local history!". Or maybe you decide to simply compare to the latest SVN Version.
So off you go, right-clicking on the file, selecting "compare", and then choosing a comparison target. Often, this is a perfectly reasonable decision. Well done, good sir.
There is, however, a quicker way to easily see the changes you've made to your code in an editing session, or even across sessions: Quick Diff
On the left side of your Eclipse editor is the "ruler" bar. It's the thing with the line numbers. And if you have Quick Diff enabled, it's also the thing with the pretty colors showing you what lines have been added, changed, and deleted. Here's what Quick Diff looks like when I change a line of code and then hover over the ruler bar color decorator:
Notice there's an "F2 for focus" line at the bottom of the popup. Here's what it looks like when you do that:
What's cool is that you can select this text from the popup. So if you see something in your Quick Diff that you think "OOOH! That's the code I monkeyed with. Let me grab that and drop it back in and see if that fixes my problem", you can simply copy it from the popup and off you go.
"Added" lines of code will merely result in a "+" for each added line in the popup; Changes will show the full lines that were changed (though they won't give you the nifty "Compare Editor", which is one of the compelling reasons for using the full-on "Compare With" stuff). Deleted lines will give you a small line in the ruler bar. For example, I deleted a function, hovered over the black line, and this is what I got:
To enable Quick Diff, simply open the Eclipse preferences (ctrl-shift-L, ctrl-shift-L), filter on "Quick", select the "Quick Diff" label, and have at it. Here you can also choose the Reference Source and change colors. It looks like this:
I use "Pristine SVN Copy" as the source for projects connected to SVN, and "Version on Disk" for non-SVN projects.
Bottom line: Enable Quick Diff, then hover in the gutter for popups showing you what’s changed. F2 to focus so you can select code