Friday, January 16, 2009

Eclipse - Efficiently using shortcut keys


I’ve found a few Eclipse shortcut tutorials around that explain how to access features through shortcuts in Eclipse. One of the most useful I’ve found, and use all the time is the old CTRL+SHIFT+R shortcut for opening a resource.  I’ve noticed that there are a number of these documented within the Eclipse help menu here:

You can also view a list of common shortcut keys using the shortcut:
CTRL+SHIFT+L
http://blog.oogly.co.uk/wp-content/uploads/2009/01/shortcutkeys.jpg
From here you can also access the key bindings menu by hitting CTRL+SHIFT+L again (as indicated in the diagram).  This allows you to remap the key bindings or setup new key bindings.  Eclipse also supports Emacs type bindings.
There are also a number of cheat sheets on the internet that you can print out and stick on the wall (or cubicle or whatever) to help you out. I’ve not found an editable template for these so I created my own in Microsoft Word format which can be found below.  This includes a list of the shortcuts I commonly use on a day to day basis.


CTRL+SHIFT+G – search references of class in workspace

SHIFT+F2 – open external javadoc

ALT+LEFT ARROW – back

CTRL+SHIFT+O – organize imports

CTRL+M maximalize window

ALT+SHIFT+J – add javadoc

Ctrl+Shift+O -  is a really big one. Just enter unqualified class names and use Ctrl+Shift+O to resolve everything. If there’s only one class with that name, it will be auto-imported. If there’s more than one, you get a dialog similar to Open Type in which you can choose the correct class.

Ctrl+Alt+H - (show call hierarchy) is another I use on a daily basis.

Shift+Alt+L  - extracts an expression to a variable.

Alt+Shift+W: “Show in…”, easy way to highlight the file you’re currently editing in the Navigator panel.

Alt+Shift+T: Refactor sub-menu

Alt+Shift+S: Source sub-menu

Alt+Shift+V: Move (refactor)

alt+shift+S R – generate java bean getters and setters for fields

alt+shift+S V – override methods

alt+shift+S O – generate constructor from fields

alt+shift+S C – generate constructors from superclass

alt+shift+M extract method

alt+shift+L extract variable

alt+shift+I inline variable

alt+shift+C change method sig

alt+shift+Z surround with
 

Open Type (Ctrl-Shift-T) -  to open a class, and Open Resource to browse to a file.

Ctrl-O in a class definition brings up Quick Outline. Start typing a member name and hit return once it’s unambiguous. Combined with Open Type this is a lightning fast way to go to any method in any class.

Ctrl-F6 is a great way to jump around between open editors. 

Ctrl-F7 does the same for views

Ctrl-F8 for perspectives.

Shift-Alt-X T to run the unit tests in the class you’re working on.

Alt+Shift+W: “Show in…”, easy way to highlight the file you’re currently editing in the Navigator panel.
Alt+Shift+T: Refactor sub-menu
Alt+Shift+S: Source sub-menu
Alt+Shift+V: Move (refactor)

No comments:

Post a Comment