Whenever you hover over any piece of code in Eclipse, it pops up a tooltip that displays more information about the item, such as its declaration, variable values or Javadoc information, as in the example below.
Although useful at times, this becomes extremely annoying after a while, especially when you’re using your mouse to browse some code. Popup after popup of unwanted information keeps obscuring your view of the code, leading to some lengthy expletives and big productivity loss. It’s useful information, but not every time all the time, almost like your car’s GPS giving you directions to 10 different places at once while you’re still parked in the driveway.
Luckily there is a way to alleviate the problem and all it takes is changing some preferences in Eclipse. We don’t want to completely disable tooltips (they can be useful), so I’ll show you how to tell Eclipse to bring up the tooltips only when you request them.
Show tooltips only on request
To tell Eclipse to only show tooltips on request, do the following:
- Go to Window > Preferences > Java > Editor > Hovers.
- Select the Source item in the list. Make sure the entire row is highlighted and that the checkbox is selected.
- Move focus to the Pressed key modifier while hovering field, positioning the cursor at the end of the default value Shift. Press and release Ctrl. The value should now read Shift+Ctrl. If you made a mistake, just clear the field by pressing Backspace or Delete and try again.
- Select the Combined Hover item in the list.
- Move focus to the Pressed key modifier while hovering field and press Shift. The value should now read Shift.
- Click Ok to accept the changes.
The preferences should look something like this:
You should now notice the following:
- If you want to show the Javadoc or the declaration of some element hold down Shift while hovering over the element.
- Variable values won’t popup automatically anymore. To show a variable’s value in debug mode, press Shift and hover over the variable. This is probably the only time when it’s a bit of a hassle to press Shift, but the pros totally outweigh the cons here as I view variable values a lot less than the number of times annoying tooltips appear.
- If you want to show a quick preview of a method’s code, press Ctrl+Shift and hover over the method. This is a nice feature combined with the tooltip enrichment Eclipse provides, so you can view a method’s code in a scrollable tooltip without having to navigate to the method and back again.
Other options – configure, disable or use the keyboard
You can, of course, choose your own modifier keys in Preferences, but these are the ones I found that work the best, especially given that Ctrl and a click is a way to go to an element’s declaration or implementation in Eclipse. I’ve found Shift to conflict the least with existing features and easy enough to use on a frequent basis. Keep in mind that 2 hovers can’t share the same modifier key (which is why we reassigned the Source hover to use Shift+Ctrl).
You can also disable tooltips completely by deselecting the Combined Hover checkbox in the preference above, but I’ve found the Shift key to be a nice middle ground so keep it enabled.
To get similar information using the keyboard, press F2 while the cursor’s positioned on the code. To show variable values in debug mode, press Ctrl+Shift+D. A nice tip if you’ve disabled tooltips completely.
Related tips
- Add comments and Javadocs in Eclipse with a single keystroke
- Always run/debug the last launched class instead of the selected one in Eclipse
- Use Fast Views to maximise screen space
- Categorise projects in the Package Explorer to reduce clutter in Eclipse
- Get warnings about unused method arguments from Eclipse to keep code clean
Let me get this straight: You are annoyed by helpful Eclipse popups, yet you’ve got annoying SnapShots plugin in WordPress activated…
Thanks for pointing that out, christian. Apparently this is a WordPress.com feature called mShots, enabled by default on all WordPress.com blogs. I never knew that (a) it was enabled and (b) I could disable it for the blog. It should now be disabled.
I normally disable the snapshot previews globally on WordPress blogs (Turn Site Previews Off), so never really noticed it on my blog. But this is only per browser/client and until you pointed it out, I never thought that it was an option you could set per blog.
And as I point out in the post, the popups in Eclipse are useful, but just not all the time. I’d say I normally only use them 5-10% of the time, so the rest of the time they’re just in the way.
Thanks again for the comment.
Thanks for posting this Byron.
At last was able to control the hovers, the way I want.
Pleasure, Millon. Glad I could help.
Thank YOU, I was about to go crazy over this (who in their right mind leaves something so annoying in a product for years anyway?)
Pleasure Gorgonzola, I’m glad it’s working better for you now. It felt like I was fighting shadows.
The other one that got to me as well was launching the currently selected class instead of the last one you launched. I’m not quite sure why they picked the default they did but anyway.
Thanks a lot for tip concerning tooltip!
Oh, thank you! Really thank you! That’s great, solved the biggest problem I had with eclipse for more than one year of using…
Thank you! Just what I needed!