Top 10 (not so popular) Eclipse Shortcuts

May 19th, 2009 Handerson Gomes, Consultant  (email the author)

I’m fortunate enough to spend a good part of my days writing code in an IDE and I believe that we can always be more efficient even if that means reaching the mouse less frequently.

I’m an earlier Eclipse user, and throughout the years I’ve learned a lot of helpful shortcuts. Most of them are very popular like the ctrl+s to save and F3 to open declaration. Here are my top 10 not so popular shortcuts available in Eclipse 3.x and by consequence IBM Rational Application Developer 6 (RAD) and newer versions.

These shortcuts not only allow me to navigate easily through the source code, but also helps me stay focus on the code I’m writing and making refactoring a second nature, which by the end of the day tends to improve the overall quality of the software.

1. Open Resource (ctrl+shift+r)

This one is probably the biggest time saver of all shortcuts. This shortcut allows you to open any file in your workspace by only typing the first letters of a file name or a mask, like applic*.xml. The only drawback of this shortcut is that it is not available in all perspectives. ctrl+shift+R Open Resource

2. Quick Outline (ctrl+o)

Do you want to view the methods of the current class or navigate to a specific method without having to scroll down the code or use the find function? ctrl+o is the answer. It will list all methods and attributes of the current class and you can just start typing the name you want and then press enter to navigate directly to that method or attribute.

ctrl+o Quick Outline

3. Quick Switch Editor (ctrl+e)

This one will help you navigate through the open editors. You can use ctrl+page down or ctrl+page up to navigate to the next and previous tabs, but ctrl+e will be more effective when you have a lot of files opened.

ctrl+e Quick Switch Editor

4. Assign to local variable (ctrl+2, L)

During development I’m used to first write the method invocation, like Calendar.getInstance(), and then assign the return of the method to a local variable using this shortcut. It saves me the time to enter the class name, variable name and also the import declaration. The ctrl+2, F is similar but will assign the return of a method to a field in the class.

5. Rename (alt+shift+r)

Renaming attributes and methods was a big deal years ago, using a combination of search and replace that frequently would lead to broken code. Every modern Java IDE today provides refactoring capabilities and Eclipse is not different. It is so easy to rename variables and methods names that once you get used to it you’ll be renaming it every time you think it is necessary or when a better name is recommended in code review sessions. To use this shortcut just move the cursor to the attribute or method name and press alt+shift+r, enter the new name and press enter. Done! All references to this method in every class in the project will be renamed automatically. If you’re renaming an attribute of a class you can press alt+shift+r twice, it will display the Refactor Dialog which allows you to automatically rename the gets and set methods also when refactoring an attribute.

6. Extract Local Variable (alt+shift+l) and Extract Method (alt+shift+m)

Refactoring also includes extracting variables and methods from blocks of code. These two shortcuts allows us to do exactly that. Do you want to create a constant from that String? Just select the text and hit alt+shift+l. If that same string is in other places on the same class it will automatically be replaced there. The Extract Method is also very helpful and clever enough to know (in most cases) the arguments that must be used when you want a section of your code to be exposed as a new method. Breaking larger methods in smaller well defined methods is one of the best ways to reduce cyclomatic complexity and also to improve testability of your code.

7. shift+enter and ctrl+shift+enter

Shift+enter adds a new blank line right above moving the cursor to the new line. The difference between a regular enter is that the cursor doesn’t need to be at the end of a line. The ctrl+shift+enter does the same thing adding the line right before the current line.

8. Alt+arrow keys

This one is a big time saver too. It will move the current line or selection up or down. Very helpful when moving sections of code  in try/catch blocks.

9. ctrl+m

We all know how productive a big screen is and the ctrl+m shortcut will maximize the editor view.

10. Next Error (ctrl+.) and Quick Fix (ctrl+1)

ctrl+. moves the cursor to the next error or warning in the current file. I use this almost always in conjunction with ctrl+1 which is the suggestion shortcut. New versions of Eclipse are pretty clever on the suggestions, helping you sort out a lot of problems like missing arguments in methods, throw/catch exception, unimplemented methods, etc.

ctrl+1 Quick Fix

If you want to view more shortcuts you can type ctrl+shift+L in Eclipse.

Feel free to share your favorites shortucts using the comments.

Be Sociable, Share!

Entry Filed under: Agile and Development

30 Comments Add your own

  • 1. James Ervin  |  May 19th, 2009 at 3:20 pm

    I had to mention one that you forgot to mention. I always tend to you Ctrl-Shift-T, which is open type instead of open resource. From a java coding perspective, I think it is far more useful.

  • 2. Peter Hendriks  |  May 19th, 2009 at 3:25 pm

    My favorite is the Ctrl+3 shortcut: open views, prefs, etc. all in one shortcut!

  • 3. Vadim Berezniker  |  May 19th, 2009 at 7:56 pm

    I was going to mention Ctrl+3 as one of the best unknown shortcuts/features, but someone beat me to it :)

  • 4. teo  |  May 20th, 2009 at 3:35 am

    OMG! I’ve been looking for “go to the next error” for sooo long!

  • 5. jakob  |  May 20th, 2009 at 5:58 am

    My “refactoring combo”::

    Alt+Shift+Arrow keys to select a Java expression, then Alt+Shift+(L|M|T) to extract a variable, method or to open the refactoring menu.

  • 6. Handerson Gomes  |  May 20th, 2009 at 8:12 am

    I would like to thank you all for the contribution. The Ctrl+3 is really a neat shortcut.

  • 7. Ignacio Coloma  |  May 20th, 2009 at 2:46 pm

    Shift + Alt + S, R -> Generate getters and setters.
    Shift + Alt + S, O -> Generate Constructor using fields.
    Ctrl + Alt + Arrow keys -> Duplicate selected code.

    It’s funny, I had to open eclipse to find these out. I don’t know the keys, only the arcane gestures over the keyboard :)

  • 8. Eduardo  |  May 20th, 2009 at 3:32 pm

    The shortcut I use more often is “Next Editor”, however, its default key bind is not intuitive: Ctrl+F6. Change it to Ctrl+Tab and be happy :)

  • 9. PRSoluções » Blog&hellip  |  May 20th, 2009 at 6:49 pm

  • 10. kodeninja  |  May 21st, 2009 at 6:47 am

    One very nice feature (although not a shortcut) in the Eclipse editor is the ability to automatically escape the data being pasted into a String literal. It’s disabled by default, so you need to enable it under Window -> Preferences -> Java -> Editor -> Typing.

    Quite helpful when pasting, say, file/directory paths under Windows, which use ‘\’


  • 11. Alipio Krohn  |  May 26th, 2009 at 12:28 pm

    Great Handerson !!!

    Congratulations for the new blog. Excellent !


  • 12. cmars  |  May 26th, 2009 at 5:25 pm

    F3 -> Open Declaration
    Ctrl-Alt-H -> Open Call Hierarchy

    Invaluable when getting to know a new codebase.

  • 13. Rahul Kamra  |  June 1st, 2009 at 8:29 am

    My personal favorite Ctrl + D : Delete the current line , very handy when you want to remove white spaces

  • 14. Suresh Reddy  |  June 18th, 2009 at 12:31 am

    hi your shortcuts are very help ful

    thank you very much

  • 15. shortcut-finder  |  February 22nd, 2010 at 10:07 am

    this is a good list of eclipse shortcuts

  • 16. Javin Paul  |  January 7th, 2011 at 11:23 am

    here is my list of useful eclipse shortcut I would rather say very useful and practical eclipse shortcut :)

  • 17. showman  |  October 5th, 2011 at 5:08 am

    alt+shift+a columnar selection

  • 18. showman  |  October 5th, 2011 at 5:16 am

    ctrl+shift+l eclipse shortcut popup
    tap it twice and the preferences dialog will open

  • 19. Jon  |  November 15th, 2011 at 1:37 am

    Don’t forget about Ctrl+2, R for a local rename which is a much quicker operation than a refactor rename in large codebases usually.

  • 20. Andrew Traudes  |  November 26th, 2012 at 6:24 pm

    Not specific to Eclipse, but select multiple lines and Tab to indent them all at once instead of one by one. Most people know about that one, but here’s the killer: Shift-Tab to do the opposite :-) That one made me really happy, especially when editing HTML, Javascript, JSP, etc.

  • 21. Zaheeb  |  December 14th, 2012 at 7:54 am

    Alt+Shift+X, T (for a Junit) or J (for a Java Application) and many others as well.

  • 22. me  |  October 23rd, 2013 at 9:19 am

    Alt Gr + C svn commit
    Alt Gr + U svn update

  • 23. Malte  |  October 31st, 2013 at 3:45 am

    Very nice selection of shortcuts, thank you for that!

    This shortcuts are also very useful in many ways:
    alt+shift+arrow up/down to expand/reduce the current selection logically (expression, block, method).
    This can for example be used for a fast debugging: Turn the cursor to a position of an expression you want to evaluate, press alt+shift+arrow up so often, until the wished expression is fully selected and then strg+shift+i to show the evaluated value.

  • 24. FRIV  |  April 17th, 2014 at 9:32 pm

    What’s up, just wanted to say, I enjoyed this blog post.
    It was helpful. Keep on posting!

  • 25. farmville 2 gratuit  |  April 19th, 2014 at 7:34 am

    Greetings! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche.
    Your blog provided us useful information to work on.

    You have done a marvellous job!

  • 26. best shower radios  |  July 23rd, 2014 at 1:50 am

    Hi! This post could not be written any better!

    Reading through this post reminds me of my previous room mate!
    He always kept chatting about this. I will forward this article
    to him. Pretty sure he will have a good read. Thanks
    for sharing!

    Feel free to surf to my site; best shower radios

  • 27. shaving cream colored eggs  |  July 23rd, 2014 at 10:37 pm

    There’s definately a lot to find out about tis topic.
    I like all the points you have made.

  • 28. subway gratuit  |  July 24th, 2014 at 2:36 pm

    Superb, what a website it is! This web site provides useful facts to us,
    keep it up.

    My blog post … subway gratuit

  • 29. what is best diet pill for women  |  July 24th, 2014 at 9:36 pm

    The first of the calves and the more of prescription diet pills that work
    fast a healthcare provider as soon as you go to fast weight loss, but tasty snacks.

  • 30. best over the counter diet pills that work fast  |  July 26th, 2014 at 9:18 pm

    Omega 3 is not an effective weight loss, are usually sessions lasting most effective diet pills for weight loss 60 minutes
    or less. If you do is squat but do we cut back your weight loss?
    You are able to eat carbs, too, can be a viable option for individuals most effective diet pills for weight
    loss who wish to shed. You can start most effective diet pills for weight loss with as little as 5 months.

    So it is very good for health.

Leave a Comment


Required, hidden

3 + seven =

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed

© 2010-2014 Summa All Rights Reserved