Awesome Eclipse Shortcuts

logo_eclipseUp until a few months ago, my primary IDE was either TextMate for OS X or just plain old Vim.  However, I’ve been working more with Java under version control over the past few months, so Eclipse + Subclipse became a more sensible option.

I’ve used Eclipse on and off for Java development over the past few years, but I am by no means a “power user”.  However, with the help of my friend Derek, Google, and a bit of good old clicking around, I’ve discovered some pretty awesome Eclipse shortcuts.

Run/Debug (F11/Ctrl + F11)

An oldie but a goodie.  I think this is the first shortcut that everyone learns when they first use an IDE.

Go To Line…(Ctrl + L)

GoToLine
You can jump directly to a line in your class file by pressing Ctrl + L.  This will bring up a new window where you can enter your line number and poof, you’re there!

Outline of Current Source (Ctrl + O)

OutlineOfCurrentSource Say you’re working with a 500 line class file, and you need to jump to the definition of a variable or method.  You could scroll around looking for it, or you could use the “Outline of Current Source” command.  By pressing Ctrl + O, Eclipse will open a little submenu listing all of the member variables and methods in the current class.  Start typing the name of the variable/method that you want to jump to, and Eclipse will automagically shorten the list.  Kinda like Quicksilver.  And we all know much much I love Quicksilver!

Open Resource (Ctrl + Shift R)

OpenResourceNow consider that you’re working with multiple class files spread out over multiple packages.  It’d be a pain if you had to hunt through the package tree everytime you needed to find a class.  You already know the name of the class that you’re looking for, but you don’t know where it’s located.  Open Resource to the rescue!  Press Ctrl + Shift + R to open the Open Resource window.  Start typing out the name of your class, and Eclipse will automatically find the class file that matches your input.

Search Workspace (Ctrl + Alt + G)

SearchWorkspaceYou can use this nifty shortcut if you want to look for all occurrences of a certain snippet of code within your workspace.

Simply click on a method/variable, or highlight a portion of code.  Press Ctrl + Alt + G, and Eclipse will show you all occurrences of that snippet in the search window at the bottom of your screen.  You can also click on those entries to immediately view the code at that location.

View Definition (F3)

Sometimes you’d be reading through some code, and you think to yourself: “What the hell does that method do?”.  Well you can answer that question quite easily by setting your cursor on that method and pressing F3.  Eclipse will then take you to that method’s definition.  The same trick works for variables as well.

Fix Indentation (Ctrl + I)

Code re-factorization occurs frequently, but it shouldn’t have to be painful.  Don’t you hate it when you have to fix the tabs whenever you decide to add/remove a for loop?  You can fix that in Eclipse by highlighting any portion of code and pressing Ctrl + I.

Refactor (Alt + Shift + T)

Ah, the Refactor tool.  An entire book could be written on this immensely powerful tool.  Everything about it is amazing; except for the fact that you have to hunt through a huge menu tree before you can find the tinsy winsy “Refactor” sub-menu.

Make you’re life easier and use the Alt + Shift + T shortcut to bring up the Refactor menu on any selected item.

And there you have it folks, eight really useful Eclipse shortcuts/tools.  This list isn’t by any means the end all and be all of awesome Eclipse shortcuts.  Hell, I’ve probably only scratched the surface of Eclipse’s tools, and there are many more to be found.

But at the end of the day, the true usefulness of any shortcut/tool can only be determined by the coder that uses it.  So go out there, play around with Eclipse and see what works for you.

This entry was posted in Eclipse, Tech and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. Posted July 5, 2009 at 1:47 pm | Permalink

    Nice post! Definitely a good guide to becoming more productive in Eclipse! Will there be a second post with more shortcuts?

  2. Posted July 9, 2009 at 10:00 am | Permalink

    @Derek
    Maybe? I found those shortcuts to be the most useful for my own needs. If I find more that are really great, I’ll be sure to make another post!

  3. Posted July 27, 2009 at 5:49 pm | Permalink

    Thanks for putting this list together, it turns out that F3 is really what I have been missing. So often I accidentally trip triggers when copying code.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>