Wednesday, January 20, 2010

My Top 10 Commonly Used Eclipse Shortcuts

Since getting reaquainted with the Eclipse IDE in the past few months I thought I'd share my top 10 most commonly used keyboard shortcuts (along with some commentary of course):

  1. Alt + Up or Down Arrow: This shortcut moves a line of code up or down based on the directional arrow you choose. Identation is respected so if you move a line of code inside of something like a loop or conditional you maintain formatting.

  2. CTRL + Shift + F: Formats the code. This is a real time saver especially if you have a custom formatter defined for your workspace.

  3. CTRL + Alt + Up or Down Arrow: Duplicates a line of code. I find myself using this shortcut when making variable declarations.

  4. CTRL + Shift + T: Opens a Type. Simliar to CTRL + Shift + R (open a resource) but this is more precise when you're truly looking to find a type and not a file in your workspace.

  5. CTRL + Shift + O: Organizes imports. My code always feels amateur until I remove all of the unnecessary imports along with removing the blanket import statements (e.g., some.package.*).

  6. Alt + Shift + R: Refactor. I'm not sure when Eclipse added the UI-sugar that live updates your code during a refactor operation but I like it!

  7. CTRL + H: Search, not find. Not a huge fan of the search utility but sometimes it can't be avoided.

  8. CTRL + /: Toggle Comment. Another huge time saver especially when you're trying to diagnose an offending block of code. For the purists at heart, the CTRL+Shift+\ and CTRL+Shift+/ add and remove (respectively) block comments.

  9. CTRL + W: Close window. Definitely not revolutionary but I feel this one is often overlooked.

  10. CTRL + L: Go to line. For the moments when your stack traces appear in a separate log file and not in a console inside of eclipse (where a hyperlink is usually provided if the source is available).

1 comment:

MRR said...

I'm not sure of the Windows equivalents, but on OS X I use the following Eclipse shortcuts:

Cmd+G - Search for occurrences of selected item in workspace.

Cmd+T - Display type hierarchy for the selected item.

Shift+Cmd+F11 - Run last launched program.