The following sentence is false. The preceding sentence is true.

Menu

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 variableor 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.

Also for anyone else reading this 4 years later, CTRL+ALT+H will do the same thing, but will also do this really neat thing of showing the call hierarchy so you can see where the execution thread is going without having to trace it yourself!
Its already been mentioned further down but I thought I’d attach it to the top post :)

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!

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…

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.

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! :)

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.

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.

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.

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.

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.

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?

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.

Hi guys,
I have been using eclipse for quite a while now but haven’t been able to find a particular which I think exists.
Many sites offer code with line numbers, when we do a copy/paste the line numbers too get copied, Could anyone suggest a shortcut to remove all the unwanted line numbers at once?

Anyone know of a shortcut that stacks declarations? F3 takes you to a declaration, but is there a shortcut to get you back to where you were? Another editor I’ve used will actually stack the jumps to var/method/class declarations, so you can jump to a declaration, browse around, then jump to another declration, etc. When you’re done, you can backtrack to where you started. Is there a counterpart to F3?

Any update on your question of jumpinig back from a declaration..? I’m looking for the same feature… I saw proposals to use Alt left but this is doing “Back” instead of stacking the declarations…
Please advice.

Best intro article on Eclipse keyboard shortcuts, after learning which one could easily be motivated to learn and use most other Eclipse shortcuts as specified in its 2-page shortcut default conf cheat sheet.

this article is awesome
can anyone tell me if there is a way to link files to one another. I know you can provide links using Javadoc comments, but that has limitations that it will only link to other Java files and they must be in the same package.

What I would like is all three: My Java file, the related Junit test case and the related Junit tescase(usually a .cpp file) should have links to each other.
And these reside in different packages, and I cannot put them together.

Re: switching between editors/files.
As soon as I install Eclipse, I like to immediately remap the next/previous editor shortcuts to ctrl-tab and ctrl-shift-tab.
As natural as switching tabs in Firefox – this is the number one shortcut I end up using on a daily basis.

This one is great but even better doen in Netbeans. Actually this is a reason for me to prefere Netbeans over Eclipse sometimes. (Not trying to start a flame war here but just to increase the motivation to find an answer to my question ;)

In Netbeans hitting Ctrl + Q twice takes you to the position before the last change, three times to the one before that, and so on. You can ride through your history of change positions. This is awsome.

Does Anybody have an idea how to achieve this in Eclipse? I miss this sooo desperately when working in Eclipse.

Even after all this time, this post is still hugely helpful (especially the comments). My question is how come this information isn’t obvious from within Eclipse itself?? For example, I didn’t even know ctrl-r “Open Resource” even existed! It’s not in any menu nor book I’d ever found….without this post, I’d have never know about…incredible!

Thanks for a good article. This will save me and my company a lot of time. Even though this article starts to get a little old, everything works fine, but an updated version with more shortcuts had been great;)

Also a little approximation, Alt + left/right arrow is not only to jump between files. It’s very convenient combined with F3. For example, press F3 on a call to a private method, you’re going there. Then Alt+left arrow brings you back to the call.

One that i found very interesting which helped me a lot these days was:

Ctrl + H

It opens a Search window for all your workspace, not only for a file or a project, but for all your projects inside your workspace.

On this window there are many tabs for the types of archives, i use the file search. I can see all the ocurrences of a specified String in my workspace and then replace it for another thing. Incredibly useful, and much more broad than a simple Ctrl + F.

Ctrl+T does more than just navigate to super- and subclasses. Put the cursor on a method and hit Ctrl+T, and selecting the super- or subclass will take you to the declaration/implementation of that method in that class.

I try to learn every shortcut key I can and not only did your list teach me a couple new ones, your advice to check out that section of “Help Contents” revealed a few more gems.

I was reluctant to check the help section because I thought just going to Preferences > Keys would be better but no! The help section highlights a lot of good shortcuts that would take a long time to uncover by searching through Preferences > Keys!

abdennourtoumi, I agree, however knowing it by heart allows you to train your muscle reflex. When it becomes second nature, you don’t even need to pause, and your programming flow doesn’t need to be interrupted to look at the list :)

An outstanding share! I have just forwarded this onto a co-worker who had been conducting a
little research on this. And he actually bought me dinner
due to the fact that I found it for him… lol.
So allow me to reword this…. Thanks for the meal!!
But yeah, thanx for spending the time to talk about this matter here on your website.

The primary processes were simpoy used to slow cook pigs but
throughout time and in distinct areas of the country, it became commonly used
to cook hamburgers and hotdogs, too.Try to make it as waterrproof aas
possible at the bottom. Everyone knows real barbecue means slow
cooking a huge hunk of meat for hours over smoldering wood or charcoal.

Hi there! This article couldn’t be written any better! Reading through this post reminds me of my previous roommate!
He constantly kept preaching about this. I most certainly will forward this post to him.
Pretty sure he’s going to have a good read. Many thanks
for sharing!

Ashe also has a talent known as Hawkshot which lets you see whats infront of
you by firing an arrow inside the direction you would like
to determine. Knowing when to move up and pressure and when to play defensive
while free farming is the characteristic of not only a great ADC but of any good laner in League
of Legends. The premise of the game is to control one of many champions and fight
your way past hordes of spawning troops (called creep), then advance past towers to destroy the enemy base.

Attractive section of content. I just stumbled upon your website and in accession capital to assert that I get
actually enjoyed account your blog posts. Anyway I’ll be subscribing
to your augment and even I achievement you access
consistently quickly.

My favorite part about Ctrl+Shift+T is that you can just type in the capitalized initials. For example, if a class is named AbstractAutomotiveVehiclePart you can type AAVP and that class (and others who happen to have the same initials) shows up.