The Curious Schemer

10 Eclipse Navigation Shortcuts Every Java Programmer Should Know

Posted in Java, Technology by rayfd on May 20th, 2007

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!

Opening a resource in Eclipse

  • 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).

Opening a type in Eclipse

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

Browse Member

ctrl_o_2.jpg

  • 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 a line number

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

Subtype hierarchy view

Supertype hierarchy view

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

Open editor

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

75 Responses to '10 Eclipse Navigation Shortcuts Every Java Programmer Should Know'

Subscribe to comments with RSS or TrackBack to '10 Eclipse Navigation Shortcuts Every Java Programmer Should Know'.

  1. Carlos said, on May 21st, 2007 at 10:40 am

    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.

  2. Paul said, on May 21st, 2007 at 12:45 pm

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

  3. selman said, on May 21st, 2007 at 2:22 pm

    hi,
    these are great!
    thanks for sharing….

  4. Nick said, on May 21st, 2007 at 2:29 pm

    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!

  5. rayfd said, on May 21st, 2007 at 2:42 pm

    Ah yes, many thanks, Nick! I have updated the post to reflect this :)

  6. rayfd said, on May 21st, 2007 at 2:42 pm

    selman, great to hear that you find it useful :)

  7. sukija said, on May 21st, 2007 at 2:58 pm

    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. ;-)

  8. Venkat Burri said, on May 21st, 2007 at 3:37 pm

    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

  9. Venu said, on May 21st, 2007 at 4:14 pm

    Ctrl+F3 also shows the list of the functions in a class. I never knew Ctrl+o is also mapped to the same dialog.

  10. Murali said, on May 21st, 2007 at 5:03 pm

    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+

  11. cherouvim said, on May 21st, 2007 at 5:45 pm

    Great post!

    I wish I had some of those in Netbeans.

  12. sudharson said, on May 21st, 2007 at 6:29 pm

    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

  13. cherouvim said, on May 21st, 2007 at 6:52 pm

    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

  14. Johan said, on May 21st, 2007 at 7:12 pm

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

  15. Bobo said, on May 21st, 2007 at 8:29 pm

    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.

  16. En vrac « Au bord de la sphère said, on May 21st, 2007 at 10:03 pm

    [...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know : j’utilise la moitié. [...]

  17. [...] Eclipse shortcut keys (via http://del.icio.us/popular) (tags: eclipse java programming howto) [...]

  18. ThunkDifferent.com said, on May 21st, 2007 at 11:15 pm

    Thanks for the del.icio.us update!

    http://ThunkDifferent.com

  19. Top Posts « WordPress.com said, on May 21st, 2007 at 11:58 pm

    [...] 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 […] [...]

  20. ashish said, on May 22nd, 2007 at 12:05 am

    Good summary.
    Thanks for putting this list.

  21. Kaida Rose said, on May 22nd, 2007 at 12:53 am

    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.

  22. Samiha Esha said, on May 22nd, 2007 at 1:55 am

    Great :)

  23. Intelligent Assumptions said, on May 22nd, 2007 at 3:11 am

    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…

  24. Anonymous said, on May 22nd, 2007 at 4:06 am

    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

  25. iodugeno911 said, on May 22nd, 2007 at 6:33 am

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

  26. harshaonline said, on May 22nd, 2007 at 6:41 am

    Good One!! Thx

  27. laurent said, on May 22nd, 2007 at 7:25 am

    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;- )

  28. [...] 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 [...]

  29. ashikuzzaman said, on May 22nd, 2007 at 9:59 am

    Very useful post. I used a few of these shortcuts already.

  30. Jesper Kamstrup Linnet said, on May 22nd, 2007 at 2:38 pm

    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

  31. Franklin said, on May 23rd, 2007 at 9:25 am

    To display hierachy view of current class, hit F4 - very useful.

    Boy Eclipse if 4ever; I love it.

  32. Franklin said, on May 23rd, 2007 at 9:25 am

    To display hierachy view of current class, hit F4 - very useful.

    Boy Eclipse is 4ever; I just love it.

  33. [...] read the 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know, I tried to figure out my favorites shortcuts. I think I would go [...]

  34. Phill said, on May 24th, 2007 at 12:46 am

    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.

  35. Antoine said, on May 24th, 2007 at 4:59 pm

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

  36. links for 2007-05-25 » SDLC Blog said, on May 25th, 2007 at 12:37 am

    [...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: Eclipse ide tips shortcuts) [...]

  37. Nick Boldt said, on May 26th, 2007 at 12:59 am

    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? ;-)

  38. rayfd said, on May 26th, 2007 at 1:42 am

    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.

  39. Allan said, on May 26th, 2007 at 10:57 pm

    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.

  40. rayfd said, on May 27th, 2007 at 12:29 am

    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.

  41. Yuen-Chi Lian said, on June 16th, 2007 at 4:41 pm

    Brilliant! I wished I could digg this here, where’s the digg button? ;-)

    Cheers,
    yc

  42. rayfd said, on June 17th, 2007 at 10:06 am

    Hi Yuen-Chi, thanks! I just added the button :)

  43. techna said, on June 25th, 2007 at 12:44 pm

    i just installed ecllipse n surfing to get some tips abt working on it n found this one very helpful.
    thnx buddy

  44. Gautam Vasudev said, on June 26th, 2007 at 12:21 am

    I’ve always found ctrl+h for searching particularly useful…

  45. Dhakar said, on July 18th, 2007 at 6:25 am

    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.

  46. ramesh said, on July 26th, 2007 at 11:13 am

    good…very good help

  47. laxmi said, on July 30th, 2007 at 10:40 am

    good ………….. very good

  48. Ashwini said, on August 1st, 2007 at 6:19 am

    Refer this site for all eclipse navigation shortcuts

    http://eclipse-tools.sourceforge.net/shortcuts.html

  49. hxp said, on September 12th, 2007 at 6:40 pm

    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

  50. Ekta said, on September 14th, 2007 at 7:00 am

    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.

  51. Selvaraj said, on September 18th, 2007 at 8:15 am

    Very useful, can save lot of time in searching

  52. Dayanand said, on September 28th, 2007 at 4:06 pm

    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!

  53. sazzad said, on September 28th, 2007 at 5:50 pm

    Really useful. Thanx a lot !

  54. Deepak Kaul said, on October 11th, 2007 at 11:08 pm

    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

  55. [...] read more | digg story [...]

  56. Mahmudul Hasan said, on November 21st, 2007 at 11:08 am

    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 ?

  57. Mike E said, on December 6th, 2007 at 10:16 pm

    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.

  58. Idetrorce said, on December 15th, 2007 at 1:13 pm

    very interesting, but I don’t agree with you
    Idetrorce

  59. Maximus said, on December 20th, 2007 at 10:34 am

    I would like to see a continuation of the topic

  60. Bijay Rungta said, on January 24th, 2008 at 2:56 pm

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

  61. Mandy said, on January 24th, 2008 at 5:23 pm

    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.

  62. [...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: keyboard shortcuts eclipse development cheatsheet tips productivity howto) [...]

  63. very nice said, on January 30th, 2008 at 12:56 pm

    :)

  64. Andriy said, on February 5th, 2008 at 2:40 pm

    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.

  65. Eclipse Timesavers « My Pragmatig life said, on February 20th, 2008 at 10:12 am

    [...] More timesavers: Eclipse Tips Eclipse Navigations Shortcuts [...]

  66. Gavin said, on February 20th, 2008 at 5:01 pm

    Does Ctrl + Mouse Click go to a Type declaration in Eclipse?

    I’m using Europa, but the click shortcut doesn’t seem to work.

  67. Michael Boyle said, on February 21st, 2008 at 8:17 pm

    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?

  68. this feature is good said, on March 29th, 2008 at 1:35 pm

    very usuful tips and these are helpful to me a lot

  69. sen said, on April 1st, 2008 at 5:03 pm

    thank you so much..

  70. [...] 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. [...]

  71. [...] My new favorite Eclipse feature Eclipse Usage Tips 10 Eclipse Navigation Shortcuts Every Java Programmer Should Knowลอง Google “Eclipse shortcut” มีอยู่เพียบครับ [...]

  72. Amit Bansal said, on April 22nd, 2008 at 7:58 am

    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

  73. Sri said, on May 2nd, 2008 at 8:18 am

    Thanks…

  74. [...] 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know « The Curious Schemer (tags: eclipse productivity Java shortcuts development) [...]

  75. roger said, on May 16th, 2008 at 8:15 pm

    Note that on mac the keys are slightly different — browse resources is command+shift+R. Go figure :)

Leave a Reply