Using Eclipse Efficiently
Wednesday November 14, 2007 by Derek Young
Eclipse is a powerful tool with a lot of features. I’m always looking for tips on working more efficiently. Most of the time when I come across a page of Eclipse tips it’s just the most basic usage, like “hit F3 to go to a declaration!” I’ve tried to put together some lesser known tips and features that I see my coworkers overlooking when I stop by their cube.
Faster Navigation
If you work with interfaces a lot you’ve probably run into the issue where going to the declaration of a function brings you to the interface, not the implementation. Instead of F3, hit Ctrl-T while on the function name. You’ll see all the classes where it’s implemented. Use the arrow keys to choose the right one and hit return to go to that definition.
Remember to use Open Type (Ctrl-Shift-T) to open a class, and Open Resource to browse to a file. (Most of my coworkers seem to use only Open Resource). Although you can use Open Resource to open Java files, Open Type shows only class names making it a shorter list. Open Type and Open Resource both support wildcards. Open Type supports camel case.
Ctrl-O in a class definition brings up Quick Outline. Start typing a member name and hit return once it’s unambiguous. Combined with Open Type this is a lightning fast way to go to any method in any class.
Ctrl-F6 is a great way to jump around between open editors. The order of editors is very intuitive with most recently used at the top. I find this much better than Switch To Editor. Ctrl-F7 does the same for views and Ctrl-F8 for perspectives.
Use Shift-Alt-X T to run the unit tests in the class you’re working on. (The keystroke seems long but they are logical, Shift-Alt-X for execute, Shift-Alt-D for debug. T for test). You can really get a fast turn around time by making changes, saving the file, then Shift-Alt-X T to see if the test succeeds.
Instead of searching for all references, try searching for Write Access or Read Access references only if you only care about one type. There are usually a lot fewer writes so this can really narrow down where a variable is changed.
Instead of jumping into a reference to see what a function does, trying leaving the Declaration view open. It shows the body of any function your cursor is over without having to use any special keys so you can always glance down for reference.
Less Typing
I think of Quick Fix as a tool for writing code, not something that just corrects accidental errors. Instead of trying to type perfect code and using Quick Fix only when you make a mistake, try intentionally leaving out code, then using Quick Fix to add it in. For example, call a function that isn’t defined, passing in all the arguments you want to to take. Use Ctrl-1, Enter to create an empty version of the function with all the right parameter types. I also like Quick Fix for creating casts. I assign an expression to a variable without a cast, then use Quick Fix to add it in.
Instead of declaring a variable and then assiging the value of an expression to it, try just writing the expression, then use Quick Assist – Assign to Field (Ctrl-2 L) to generate the declaration. The variable name will be highlighted and the drop down gives you several reasonable alternatives to use for the variable name. Tab again to get to the type to choose an alternative. For example if you had new ArrayList<String>() and used Assign to Field you might choose List<String> from the list of type alternatives.
Completion on empty string works. For example if your cursor is in an empty function, Alt-/ will show some reasonable completion choices like the member names in your class.
The Rename Refactoring (Shift-Alt-R) works without having to take your fingers off the keyboard, allowing you to safely rename variables or functions quickly. Try it from the keyboard instead of the refactoring menu. Inline also works well from the keyboard (Shift-Alt-I).
To improve completion try the Content Assist – Favorites setting. Add any static imports you use frequently. You’ll be prompted for these when completing even if you haven’t imported them. Also use Type Filters to remove classes you never want to see. If I want to use java.util.List and complete on List I see antlr.collections.List at the top, which is never what I want. Adding antlr.collections.* to the type filters suppresses this.
Taking it to the next level
To get productivity increases across the board, try the Mylyn extension. It takes some getting used to but improves the UI in lots of small subtle ways—completion works better (showing interesting choices first), opening types is easier, the Package Explorer has less junk and checkins are easier when you’re working on more than one thing at a time.
Code templates can really be a time saver. Try completing on “foreach” after a collection has been declared. Most of the time you get a good loop template.
Any more?
If you have other favorite, lesser known tips, feel free to add them to the comments.

Scala vs. Groovy: static typing is key to performance Java coding decisions I struggle with

CTRL+SHIFT+G – search references of class in workspace
SHIFT+F2 – open external javadoc
ALT+LEFT ARROW – back
CTRL+SHIFT+O – organize imports
CTRL+M maximalize window
ALT+SHIFT+J – add javadoc
— ace Nov 15, 05:06 AM #
ctrl-o ctrl-o to show inherited members too!
— Chris Richardson Nov 15, 02:27 PM #
Ctrl+Shift+O is a really big one. Just enter unqualified class names and use Ctrl+Shift+O to resolve everything. If there’s only one class with that name, it will be auto-imported. If there’s more than one, you get a dialog similar to Open Type in which you can choose the correct class.
Ctrl+Alt+H (show call hierarchy) is another I use on a daily basis.
Shift+Alt+L extracts an expression to a variable.
And when in doubt, let’s not forget Ctrl+3, which lets you access any command by typing the name (or a fragment of the name).
— Daniel Spiewak Nov 15, 03:11 PM #
I would also suggest changing the hot keys combination also.
Like switching editors using Ctrl+F6 is awkward compared to Ctrl+Tab. Similarly running your java program using Ctrl+R is much more convenient.
You can change the keys from Window -> Preferences -> General -> Keys
— Chetan Nov 16, 04:02 AM #
The coolest thing in 3.3 I use is Save Actions – these are actions performed on a file each time its saved.
So – organize imports (Ctrl-Shift-O), apply source formatting (Ctrl-Shift-S), and code cleanup (add annotations, make things final, etc) all just happen without me thinking about it.
— fred Nov 16, 04:36 AM #
I love and use most of the shortcuts above, but I would suggest that if you are in a team environment to make sure that you export and share your settings so that you have consistent check-ins.
— Qaiser Nov 16, 05:26 AM #
alt-shift-upArrow
Increases the selection to next next largest java expression.
alt-shift-downArrow to decrease.
alt-shift-leftArrow to add the expression to the left
alt-shift-rightArrow similarly
— EclipseUser Nov 16, 06:54 AM #
Ctrl+M – full screen
— Sivaswami Nov 16, 10:11 AM #
@Chetan – I agree, when I set up a new workspace, the first thing I do is set the “Quick Fix/Quick Assist” key combination to Ctrl+Enter, from the carpal tunnel-inducing default of Ctrl+1 :)
One note that isn’t mentioned in the blog post regarding Open Type (Ctrl+Shift+T) is that it is also the only way (that I know of) to open class files in third-party libraries – extremely helpful.
Other nice key equivalents:
Alt+Shift+W: “Show in…”, easy way to highlight the file you’re currently editing in the Navigator panel.
Alt+Shift+T: Refactor sub-menu
Alt+Shift+S: Source sub-menu
Alt+Shift+V: Move (refactor)
Alt+Shift+Z: Surround With (generally requires a block selection) – easy way to wrap do/while, if, etc. block elements around something.
— Peter Mularien Nov 16, 10:35 AM #
Nice tips.
— MM Nov 16, 01:49 PM #
“Open Type supports camel case”
So does Open Resource, as of 3.3.
Good tips though.
— Paul Nov 17, 01:57 AM #
The best way to get productive is to switch to IntelliJ :)
seriously, are there any editor plugins that offer these:
1) duplicate line (ctrl-d in intellij)
2) direct bookmarking (ctrl-shift-1 sets bookmark 1, ctrl-1 navigates to it, ditto for 2-3-4-...)
3) column select mode
4) ability to navigate to a class and see what jar file it’s in
5) find all classes that have a “toString” method
6) code templates (like in intellij you type psvm and tab and you get public static void main)
7) xml refactoring
8) xml code completion
9) ant code hints/completion
10) groovy debugging
I’m sure some of the above must work these days on eclipse?
— phil swenson Nov 20, 04:23 PM #
Jump to next/previous opened file/tab : Ctrl + PgUp, Ctrl + PgDown
— Marius Nov 20, 10:51 PM #
Open type is also useful to find classes because it includes internal classes too. Open resources will not find them. I use a lot of shift+alt+l (to extract variable and) shift+alt+s to access source menu and shift+alt+z to surround code.
Kind Regards
— Marcos Silva Pereira Nov 21, 06:56 AM #
Here is an attempt to answer post #12. by phil swenson:
1) ctrl-alt-up
2) no bookmark shortcuts that I could find
3) I don’t think Eclipse supports this
4) ctrl-alt-t then “Link with Editor” in package explorer
5) ctrl-g from Object.toString()
6) yes, type ma then ctrl-space for your main method example
7) not sure about this one
8) ctrl-space
9) ctrl-space
10) alt-shift-d g
— Larry Zappaterrini Nov 21, 08:27 PM #
Thanks for the post and the comments. There were even some I didn’t know :)
You forgot that CTRL+SHIFT+R is open Resource. This and Open Type also support Wildcards.
CTRL+E for Open Editor List (with typing to reduce list like ctrl+o)
Does anyone know of a cheat sheet with these more advanced eclipse shortcuts? I’d like to hand them to my co-workers who still do mouse-driven development.
But I also prefer IntellJ IDEA when writing code and refactoring. Eclipse is way to slow.
— Michael Hunger Dec 23, 04:51 PM #
thanks for Ctrl + 3, and Save Action tips,
another one, Ctrl + Shift + P to go to matching bracket.
PS, eclipse does has a bookmark, try Ctrl + 3, and type bookmark
thanks all guys
— david Jan 25, 06:51 AM #
Not long time ago I created MouseFeed Eclipse plugin, which helps to learn keyboard shortcuts. The plugin can remind and even enforce keyboard shortcuts.
— Andriy Feb 7, 09:28 AM #
Ctrl -T on a method to see a quick type hierachy
— Ryan Feb 12, 01:37 AM #
also let’s not forget
alt+shift+S R – generate java bean getters and setters for fields
alt+shift+S V – override methods
alt+shift+S O – generate constructor from fields
alt+shift+S C – generate constructors from superclass
alt+shift+M extract method
alt+shift+L extract variable
alt+shift+I inline variable
alt+shift+C change method sig
alt+shift+Z surround with
^ those five are quite useful together. I’m sure we are still forgetting some.
— John Newman May 2, 06:55 AM #
alt shift r : refactor
ctrl shift f : format
alt shif j : generate javadoc
— mauhiz Jun 11, 06:14 AM #
22. How to Put author of a code in a java file using eclipse.
— Sasi Kumar Jun 19, 10:49 PM #
Ctrl-O is one of the most useful commands in eclipse which pops up a quick list of all the methods in that particular class. Is there any corresponding command in Intellij ?
— Parvinder Singh Arora Jul 24, 01:29 PM #
24. CTRL+1 will be usefull to open Error Rectify window.
—Rajesh Chowdary
— Rajesh Chowdary Oct 29, 05:08 AM #
Great stuff! Maybe it’s worth to summarize all of the hints in one new post?
— ppow Nov 4, 03:45 AM #
additional tip to answer post 12, adding to answers from post 15:
3)Alt+shift+a(column select mode)
— Charbel Jun 7, 09:46 AM #