Home > Best Practices, Opinion, Random Notes, tutorial > Favorite Eclipse shortcuts

Favorite Eclipse shortcuts

March 5th, 2009

Anyone who knows me knows that I hate touching the mouse. I do not like using it one bit. If there is a shortcut on the keyboard, its a pretty big guarantee I am going to do my best to find it. Being a programmer, I spend a massive amount of time using Eclipse. Naturally I have a pretty good understanding of all the shortcuts that make my life easier. Here a list of shortcuts that can help you. Also a brief how to on removing the most annoying shortcut of all, show in breadcrumbs.

Ctrl+space. Autocomplete.
This will recommend a list of classes they will fit what you have typed so far. If there is only one match, it will just print it out for you. After it does print it out for you, it will include the import for you. If something is ever missing the import at the top, I will just go to the Class declaration and just hit Ctrl+space.

Ctrl+Shift+R. Open resource.
I cannot live without this shortcut. It is such a time saver. Whenever you are trying to find a specific class, just start typing it and it will populate which classes match that criteria. Once you found it, select it and there you go! It also works great if you are new to a framework and need to find certain classes or if you partly recall the class name but not 100% sure.

Ctrl+O. Show inherited members.
This is another one that works great when you are working with classes with a massive lump of methods attached to it. You COULD do this within the Package Explorer, but no one likes touching that mouse! You can even type to filter down your methods. If you have methods with the same name and just different parameters, this also works great. Just type in part of the method name and get a few overview and access to each of the methods.

Ctrl+H. Loads search box.
I cant tell you how often this saves me. This isnt just a ‘find’ box, this does a ‘find in files’ within the File Search tab. Within here, you can specify what you are looking for in the files, what you file types you want to search in, etc. There are other types of search you can use, but I have not run into a case where I need them. Have you?

Ctrl+Shift+C. Comments a block of code.
This is perfect for debugging. It is strange because really when you think about it, you are only talking about having something put a /* at the begging of what you selected and a */ at the end of what you selected. However, I use this a lot more often than you would expect.

Ctrl+D. Delete a line.
Self explanatory. Extremely useful. If I didn’t have that, I’d have to waste time with Shift+End, Delete!.

Ctrl+E. Menu for opened files.
This will bring up a list of opened files that you have. Not only that, it will also allow you to type in your class names to narrow down your choices.

F4. Shows class hierarchy.
This is extremely useful when you are new to a with a massive framework and you really want to get a sense of how things are all connect, who extends what, etc. Unfortunately, this never made it into Flex Builder (bummer), but I enjoy life when I get to use it in Java land :) .

F3 and Ctrl+Left Mouse Click. Shows declaration.
I enjoy using this when I am working with larger files or anything with long methods (which always irks me). It can get extremely annoying to see where some variables are declared. All you have to do is high light the variable then hit F3. Sometimes I will hold control and hover over variable names if I am having a problem.

F5, F6, F7, F8. In debug mode.
There three shortcuts are probably used more than anything. I wanted to group them all into one section.
F5 – Step Into. When you are debugging an application and you come across a function call, F5 will step into that function and proceed from there.
F6 – Step. This allow you to debug line by line. However, this will not step into any functions.
F7 – Step out. If you are debugging in a function and you want to step out of it to where the function was called, this is what is used.
F8 – Skip to next breakpoint. If there arent any other break points to high, you will be just running the application until your application hits another breakpoint, taking you back into debug mode.

Alt+leftarrow or Alt+rightarrow. Jump back to a line, Jump forward to a line.
According to eclipse, this is “Next word, Previous word’. I am not sure what that means. All I know if I am stepping into functions, debugging through multiple files and breakpoints, this is a life saver. It allows me to retrace my steps, step by step. If I go back with Alt+leftarrow, I can go right back to where I was with Alt+rightarray.

Ctrl+Shift+L. Displays all shortcuts.
Self explanitory. Dig in and find your favorite!

This last one is not about using a shortcut. It is about what you have to do to turn it of.

Alt+Shift+B. Show in breadcrumb.
This is something that might work great for some people. For me, it annoys the hell out of me. It puts a breadcrumb in your text area and it does not give you an easy way to get rid of it. So here is how you get rid of Show in breadcrumb.

Go to Window then customize perspective. In there, go to the Commands tab. For me, I used the Java Editor Presentation. But on the Toolbars details, you should see Toggle Breadcrumb with an icon of a C and an arrow. Click on that then click okay. On your toolbar (if it wasnt already there), you should now see that icon. Click that to turn it off.

Just like any other trade, the better you know your tools, the better you will be. I am not saying this makes you a good programmer, but it does make you more efficient. If you feel I left out any shortcuts that find essential, feel free to comment!

Best Practices, Opinion, Random Notes, tutorial ,

  1. March 5th, 2009 at 10:42 | #1

    Ctrl+space Autocomplete is key!
    But the real reason I hate using MSVS and other IDEs is they don’t have the Mark Occurrences functionality which puts little white marks on the right side to show you locations of variables you highlight. This is on by default, but if not use Alt+Shift+O

  2. ashish jain
    March 5th, 2009 at 12:20 | #2

    thanks, it’s always refreshing to read about these shortcuts again. I will try few today.

  3. March 5th, 2009 at 12:53 | #3

    Nice, almost all of these are essential to help you effectively navitage through eclipse..
    I too have tried using the Java search functionality provided by ctrl+H but haven’t found a scenario where it would be a prefered option..

    Just adding a couple of more shortcuts i find useful..
    Ctrl+T. Shows quick class hierarchy.
    Same as F4, just opens up a layer similar to ctrl+O, i find it more useful than F4.

    Alt+Up and Alt+Down. Move selected lines up and down.
    Have started using this quite frequently, helps me avoid the alternate ctrl+x, up, ctrl+v..

    I have been on a search of a keyboard shortcut to clear console, no luck yet.

  4. Shoggothe
    March 5th, 2009 at 14:07 | #4

    Some more useful shortcuts for Java projects:
    Ctrl+Shift+O – auto repair imports
    Ctrl+1 – quick assist
    Ctrl+Shift+G – search references
    Ctrl+G – search implementations
    Alt+Shirt+R – rename refactoring

    And the most used at all:
    Ctrl+S – save

  5. ol
    March 5th, 2009 at 15:04 | #5

    ctrl + up/down : move seletected text up/down!
    ctrl + T : display hierarchy of the selected type in a popup (better than F4)

  6. March 5th, 2009 at 18:18 | #6

    Great blog entry! I prefer Ctrl+7 to Ctrl+Shift+C though.

  7. Neil
    March 5th, 2009 at 18:50 | #7

    Ctrl+Shift+Up/down: scroll to the next/previous method :)

  8. Spyros
    March 6th, 2009 at 04:54 | #8

    Very useful! An alternative shortcut for comments is:

    ctrl + / : comment line
    ctrl shift + / : comment block of code

  9. March 7th, 2009 at 03:26 | #9

    For Netbeans I use the following key bindings

    New – CTRL + N
    Implementors / Overrides – CTRL + ALT + B
    Delete Line – CTRL + X, CTRL + E
    Go to Line – CTRL + G

    Save All – CTRL + SHIFT + S
    Undo – CTRL + Z

    Open Type – CTRL + O
    Open Project – CTRL + SHIFT + O
    Open Symbol – CTRL + SHIFT + ALT + O
    Open Members – CTRL + F12

    Refactor / Rename – CTRL + R

    Introduce Variable – ALT + SHIFT + V
    Introduce Method – ALT + SHIFT + M
    Introduce Constant – ALT + SHIFT + C
    Introduce Field – ALT + SHIFT + E

    Replace – CTRL + H
    Duplicate Lines – CTRL + SHIFT + DOWN / UP ARROW

    Completion from buffer – CTRL + K

    Quick Fix – ALT + ENTER

    Switch between open editors – CTRL + TAB

  10. PeteS
    April 16th, 2009 at 15:30 | #10

    Very helpful — I had a hard time figuring out how to turn off the goofy breadcrumb bar until I found this article. Thanks very much!

  11. May 27th, 2009 at 08:56 | #11

    most of it does not work! very bad

  12. shone
    June 22nd, 2009 at 08:23 | #12

    Hi! Thank you so much I tried every way to get rid of the stupid breadcrumb bar but only get the answer here! what a stupid idea the breadcrumb!

  13. D
    August 13th, 2009 at 15:08 | #13

    So why doesn’t it work? I have the same issue as vp.

    I’m using Flex and want to use the ctrl+shift+o to eliminate duplicate imports and re-order them. Yet it doesn’t work. :(

  14. Simon
    September 13th, 2009 at 12:22 | #14

    Do someone knows how to make the back/forward buttons of MS explorer mouse works in Eclipse ?

  15. Dilip
    November 9th, 2009 at 16:41 | #15

    I liked the breadcrumb feature, and you are right…its very irritating to hide that…exploring that perspective stuff is boring :)

  16. Avinash
    April 8th, 2010 at 05:09 | #16

    I also had hard time in removing Breadcrum … thanks for good and organised info.

  17. May 4th, 2010 at 00:58 | #17

    Very good list. Should add Ctrl-1 for quick fix.

  18. Gene
    September 20th, 2010 at 15:50 | #18

    As someone new to Eclipse (VB programmer that’s getting a late start) these shortcut hints are extremely helpful.

  19. dB
    July 13th, 2011 at 16:35 | #19

    Another way to get rid of breadcrumb (as the described method here did not work for me) is to change the key bindings to Toggle the breadcrumb on/off. You can go to Window->Preferences. Then navigate to General->Keys and the in the filter search for breadcrumb. There “toggle breadcrumb” should appear to which you can assign some key binding operation.

    Hope this helps.

  20. Giri
    October 21st, 2011 at 14:43 | #20

    Thank alot, original description about how hide breadcrumb tool bar helpmed alot. It worked.

  1. January 17th, 2011 at 19:23 | #1