10 Eclipse Navigation Shortcuts Every Java Programmer Should Know
Man, I’m such an impatient guy. I cringe whenever I see somebody squint and frown, looking for a JSP file in Eclipse by browsing painfully through the gazillion JSPs in multiple folders in the Package Explorer. I squirm whenever I see somebody looking for a Java class by clicking through packages, one by one, backtracking if it’s the wrong package, and so on, until he sees the correct Java class.
I mean, any resource in the workspace is literally seconds away. Ditto to classes (and interfaces, and members, and so on). Why waste time and brain cycles to wade through countless lines in countless files? I thought that every Eclipse user knows this, in fact, if you’re reading this, most probably you already know this too. But thousands of Eclipse JDT users who never bother to read tech blogs in all probability will also never bother to find out what Eclipse can do for them. And it’s a pity, really, because they’re really missing out a lot. So maybe if you know one, you can forward this to them or something. Make them more productive or something, ya know. 30 seconds saved for every file can add up to really a lot!
So without further ado, let’s say you want to:
- Open any file quickly without browsing for it in the Package Explorer: Ctrl + Shift + R. This shortcut opens a dialog box that accepts the name of the file you’re looking for. It even accepts wildcard characters, yo. Typing *-conversion.properties will give you the list of all files that ends with -conversion.properties. So everytime you want to open a file–stop that hand from going to the mouse, and press Ctrl + Shift + R instead!
- Open a type (e.g.: a class, an interface) without clicking through interminable list of packages: Ctrl + Shift + T. If what you want is a Java type, this shortcut will do the trick. Unlike the previous shortcut, this even works when you don’t have the Java source file in your workspace (e.g.: when you’re opening a type from the JDK).
- Go directly to a member (method, variable) of a huge class file, especially when a lot of methods are named similarly: Ctrl + O. Say, you’re browsing through a file which has 500+ lines of code. How do you look for a method? Don’t use Ctrl + F and then type the method name. Use Ctrl + O, which gives you a list of candidates that match what you’ve typed so far. Select the member you want using the arrow keys, and press Enter. (Alternatively, if you just want to jump from one member to the next (or previous), you can use Ctrl + Shift + ↓ or Ctrl + Shift + ↑, respectively.) UPDATE: As Nick pointed out in the comments section, pressing Ctrl + O again shows the inherited members. Thanks Nick!
- Go to line number N in the source file: Ctrl + L, enter line number. Of course if the stack trace is in the Eclipse console, you can just click the hyperlink. But if it’s in a log file or something, just use this shortcut to go to the line in a jiffy.
- Go to the last edit location: Ctrl + Q for . If you have a big file, it’s annoying to jump from one location in line 1000+ to 2000+ only to realize after looking at line 2017 that you’ve made a mistake in that location near line 1000+ just now. This shortcut brings you right to where you last edited a file. Very handy in a big file. Gone are the days of “let’s see… where did I edit it again… nope, nope… ah there it is”. (This even works when you’re already looking at a different file.)
- Go to a supertype/subtype: Ctrl + T. Before I found this, if I want to go to the superclass of a class, I’d go the the very top of the file, hover my mouse over its superclass, hold Ctrl, and click. Disgusting. Now I just press Ctrl + T and I get this dialog below, which toggles between supertypes and subtypes when you press Ctrl + T again.
- Go to other open editors: Ctrl + E. I know you can cycle through the editors using Ctrl + F6 as well, but I prefer Ctrl + E because Ctrl + F6 has this annoying behaviour of requiring you to keep the Ctrl key down, and the distance between Ctrl and F6 is so far I have to twist my left hand to do that. Just press Ctrl + E, and either use the arrow buttons, or type the name of the file you’re editing.
- Move to one problem (i.e.: error, warning) to the next (or previous) in a file: Ctrl + . for next, and Ctrl + , for previous problem. No need to lift your hands off the keyboard to click on that red or yellow stripe.
- Hop back and forth through the files you have visited: Alt + ← and Alt + →, respectively. I have to admit I don’t find myself using these two often, though.
- Go to a type declaration: F3. Alternatively, you can hold Ctrl down and click the hyperlinked variable or class or whatever it is the declaration of which you want to see–but why lift your hand off the keyboard? Just press F3 and Eclipse will bring you to the declaration of whatever is at the cursor at that moment.
OK, that’s it for this post. There are tons of other Eclipse shortcuts not covered by this article. To see the whole list, just open up your Eclipse (I’m assuming Eclipse 3.2 here–in older or more recent versions this may differ slightly), go to Help → Help Contents → Java Development User Guide → Reference → Menus and Actions. The whole motherload is there, from generating comments, correcting indentations, surrounding with, and so on.
The point I’m trying to get across is: Eclipse has a LOT of shortcuts to make things real easy for you. Java (or heck, any software) development is hard. We shouldn’t make it harder on ourselves by fighting our tools! Let our tools help us as much as possible, so we all can go back on the dot and spend more time with our family, lovers, or whatever it is we want to spend more time on. There’s no honour in working hard inefficiently. Only disgrace.








Sometimes we just don’t spend the time learning how to use our development tools, and keep using Eclipse as a simple text editor. These shortcuts really make development easier. I already use a lot of Eclipse shortcuts, nut nonetheless I didn’t knew some of these
One of my favorites is CTRL+Shift+G, which searches the workspace for references to the selected method or variable.
A complete list of shortcuts can be seen with Alt-Shift-L . Going through that list is sure to teach you a few new tricks about Eclipse
hi,
these are great!
thanks for sharing….
An addition to the Ctrl + o : doing Ctrl + o once gives you the ability to quick search/jump to methods in the class you have open, doing Ctrl + o twice, gives you the same ability but then for all methods in the current class plus super classes. Very handy!
Ah yes, many thanks, Nick! I have updated the post to reflect this
selman, great to hear that you find it useful
Just today, I was hunting for a file in multiple packages in Eclipse and to find this article an hour later! Needless to say, thank you.
As purists would say - RTFM.
One of my favorites is CTRL+F6 which gives you the list of files opened in editor. Togo the last file visited CTRL+F6. To go to any other file opened CTRL+(hold) F6
Ctrl+F3 also shows the list of the functions in a class. I never knew Ctrl+o is also mapped to the same dialog.
I configured my workspace so that using the sequence Ctrl+PgDn or Ctrl+PgUp will take you to the next or previous open editors in the workspace. The thing that I find much much more useful is that you can assign your beloved key sequences to the actions that you usually perform…
One more thing, as mentioned in this article, Alt+ -> and Alt+
Great post!
I wish I had some of those in Netbeans.
Why not…. Netbeans has enough shortcuts and you can assign your own as well.
NetBeans IDE Keyboard Shortcuts: http://developers.sun.com/jsenterprise/reference/techart/shortcuts.html
Yes, but it’s missing many things that this blog post features here. For example I think it doesn’t have a “Go to a supertype/subtype” (Ctrl + T) or the granularity of CTRL+SHIFT+R that eclipse has.
thanks
The “Open Resource” feature is great, but it’s a little limited by the fact that it does not allow you to select multiple entries in the list. Maybe there is a way to accomplish this (that not includes writing a plugin
)?
I’ve remapped CTRL+F6 and CTRL+SHIFT+F6 to CTRL+TAB and CTRL+SHIFT+TAB, respectively, so that it switches between files like most other applications. Of course, this screws me when I work on other people’s machines.
[...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know : j’utilise la moitié. [...]
[...] Eclipse shortcut keys (via http://del.icio.us/popular) (tags: eclipse java programming howto) [...]
Thanks for the del.icio.us update!
http://ThunkDifferent.com
[...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know Man, I’m such an impatient guy. I cringe whenever I see somebody squint and frown, looking for a JSP file in […] [...]
Good summary.
Thanks for putting this list.
Um..
“Man, I’m such an impatient guy. I cringe whenever I see somebody squint and frown”
For a guy your a pretty exellent writer and honest. To be honest I like people squiting it’s funny.
Great
Working Smarter
I agree with rayfd. It is highly annoying watching a developer struggle to find something in the package explorer when one simple keystroke will get them where they want to go. Check it out, and drop a note letting him know you appreciate his efforts…
Here are somemore useful shortcuts
Breakpoints Shift+Alt+Q B
Cheat Sheets Shift+Alt+Q H
Console Shift+Alt+Q C
Java Declaration Shift+Alt+Q D
Java Package Explorer Shift+Alt+Q P
Java Type Hierarchy Shift+Alt+Q T
Javadoc Shift+Alt+Q J
Search Shift+Alt+Q S
Show View (View: Outline)Shift+Alt+Q O
Show View (View: Problems)Shift+Alt+Q X
Synchronize Shift+Alt+Q Y
Variables Shift+Alt+Q V
hey! thanks for the info…did u also know that you can press ctrl-alt-h to display call hierarchy? also you can easily indent your code lines by pressing ctrl-I(as in the letter “I”)…have a good time coding and hope to have more correspondence with you!
Good One!! Thx
What about another post on the java language shortcuts ( like sysout + Ctrl-Esp => System.out.print() … it’s a shame I never need to write this in my code;- )
[...] Uncategorized — ashikuzzaman @ 12:11 am A lilttle earlier I came accross this use entry of 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know . Its specially useful for me although I already use quite a few of [...]
Very useful post. I used a few of these shortcuts already.
You can also find a couple of quick reference sheets for various versions of Eclipse ready to print here: http://eclipse-tools.sourceforge.net/shortcuts.html
To display hierachy view of current class, hit F4 - very useful.
Boy Eclipse if 4ever; I love it.
To display hierachy view of current class, hit F4 - very useful.
Boy Eclipse is 4ever; I just love it.
[...] read the 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know, I tried to figure out my favorites shortcuts. I think I would go [...]
Holy crap, Ray. This post is awesome. I’m the king of taking 5 years to learn a useful shortcut. Open Reference, Type, and Hierarchy are already ones I survive on.. but CTL+Q and CTL+O look like a whole lot of fun. Thanks.
Great post !
When editing Java code, I like to be able to manage my imports automatically (Ctrl + Shift + O), and change the incrementation of the code (Ctrl + i).
[...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: Eclipse ide tips shortcuts) [...]
I can’t believe you forgot CTRL+3, the latest and greatest navigation shortcut added to Eclipse 3.3M7: http://eclipsenuggets.blogspot.com/2007/05/quick-access-ctrl3-is-bliss-are-you-one.html
If you’re still using Eclipse 3.2.x, that reason alone should make you want to step up to the latest. Why wait until the end of June?
Nick, that’s good to know–thanks!
Yeah, I’m still using Eclipse 3.2.x. We’re using a bunch of plugins for our project, so we’re not risking moving to 3.3 yet now. But that’s something to look forward to for sure.
You probably have forgotten to include Ctrl-Shift-O which automatically organizes import, quite useful when you’re getting red underlines due to unknown class declarations and warnings on unused imports.
Hi Allan–not at all! I’m featuring only 10 shortcuts, so obviously a lot of other shortcuts will not be featured although they’re certainly not forgotten. But more importantly, the shortcuts in this post are _navigation_ shortcuts, and Ctrl + Shift + O is not one of them.
Brilliant! I wished I could digg this here, where’s the digg button?
Cheers,
yc
Hi Yuen-Chi, thanks! I just added the button
i just installed ecllipse n surfing to get some tips abt working on it n found this one very helpful.
thnx buddy
I’ve always found ctrl+h for searching particularly useful…
Really good it saved a lot time ..
Can you please publish the shortcuts for some methods in eclipse so that i dont need to type full name of it.
good…very good help
good ………….. very good
Refer this site for all eclipse navigation shortcuts
http://eclipse-tools.sourceforge.net/shortcuts.html
I’m new to Eclipse shortcuts and one thing I noticed was that CTL+O and CTL+F3 are different. CTL+O will give the class members of the current file. CTL+F3 will give the class members of the currently selected class within the file. If a class isn’t selected then it then it will default to the action as CTL+O
On a java class like JFrame, or on its method I pressed F3, it was not showing any description. F3 IS NOT WORKING IN MY ECLIPSE ENVIRONMENT. Please help me out. I dont know how to change the configure settings so that F3 start working properly.
Very useful, can save lot of time in searching
You almost read my mind while coming up the list of short cuts. These are precisely the shortcuts that a Java developer craves for during the course of his Eclipse usage. Thanks a ton!
Really useful. Thanx a lot !
Use Ctrl+Shift+L to view most of this listings.
Doing Ctrl+Shift+L again will open the KEY window where you can change/add new Key Maps
HTH’s
:)eepak Kaul
[...] read more | digg story [...]
Great Post. It increased my productivity.
Is there any shortcut that will help me avoid using the arrow keys ? I don’t like the frequent journeys to the arrow keys while coding.
Just something like Vim, that uses like I, J, K, L as the arrow key ?
Regarding Ctrl + Shift + T and wildcards….
One of the nice features about the Open Type dialog (Ctrl + Shift + T) is that you can type just the uppercase letters in a class name, and it will display all classes with that sequence of uppercase letters. So if you type NPE, the results will contain NoPermissionException, NullPointerException, etc.
This feature makes it really easy to search for classes with long names.
very interesting, but I don’t agree with you
Idetrorce
I would like to see a continuation of the topic
Nice List..
I do use most of them
Thanks specially for the Ctrl + E
I was thinking of the shortcut for this for long…
Can anyone tell Whats the shortcut to find the next occurance of the string that you tried to find using Ctrl + F
F3 doesn’t seem to work here as in other editors..
Very nice! A few of these I use all the time but some others were new to me. One of my favorites that’s not on the list is Ctrl + Alt + H = Open Call Hierarchy.
[...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: keyboard shortcuts eclipse development cheatsheet tips productivity howto) [...]
Ray,
for me the main problem was remembering all the neat shortcuts I wanted to use. Finally I wrote an Eclipse plugin MouseFeed (http://www.mousefeed.com/) to help me with that. If you call an action with a mouse click, the plugin will remind the keyboard shortcut for it. You can even tell it to force you to use keyboard shortcuts - the actions called by mouse won’t run. The configuration is action-specific.
Please take a look and let me know what you think.
[...] More timesavers: Eclipse Tips Eclipse Navigations Shortcuts [...]
Does Ctrl + Mouse Click go to a Type declaration in Eclipse?
I’m using Europa, but the click shortcut doesn’t seem to work.
Does anyone know why Ctrl-E lists the files in two groups?
Yes, I know that the bottom group is the ones for which
the tabs are currently visible, but when I’m searching for
a buffer, I’m supposed to remember which buffers are
have tabs that are currently visible? Is there any way
to just list all the buffers, alphabetically?
very usuful tips and these are helpful to me a lot
thank you so much..
[...] And since it’s eclipse and there’s no point in duplicating the information, here is a useful link to 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know. [...]
[...] My new favorite Eclipse feature Eclipse Usage Tips 10 Eclipse Navigation Shortcuts Every Java Programmer Should Knowลอง Google “Eclipse shortcut” มีอยู่เพียบครับ [...]
Hi All,
I have a problem with WSAD5.1 Editor. when I clicked left mouse button with Holding down the ctrl key on any variable or mathod in a file then that method declaration is opening in a new window. now the problem is that I am able to see only the declaration in that file and not full file. while previosly I was able to see the full file.
please if you know the solution or is it due to some setting changed then please let me know ASAP.
Thanks
Thanks…
[...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: eclipse productivity Java shortcuts development) [...]
Note that on mac the keys are slightly different — browse resources is command+shift+R. Go figure