Eclipse: Essential Shortcuts
Gene De Lisa
Introduction
The Eclipse IDE has a reasonable set of keybindings configured. You can see the default set, choose an alternate set resembling Emacs or define your own. Open the Preferences dialog by pressing and then in the preferences tree on the left choose . The dialog may be slightly different in your version of Eclipse/RAD/WSAD. There are quite a few key bindings available. Here I will list the few that I use all the time.
Eclipse Key Bindings
Key bindings can be modified by the Control key (Ctrl), the Shift key (Shift) or the Alt keys. In the following table Ctrl-N means hold down the control key and press n. You do not type the dash. The sequence Ctrl-Shift-S means " hold down control and shift at the same time and then press s".
| Action | Key sequence |
|---|---|
| Save | Ctrl-s |
| Save All | Ctrl-Shift-S |
| Display the New Dialog | Ctrl-n |
| Format Code | Ctrl-Shift-F |
| Organize Imports | Ctrl-Shift-o |
| Display Javadoc | Shift-F2 |
| Popup Outline | Ctrl-o |
| Content Assist | Ctrl-space |
| Show matching brace | Ctrl-Shift-p |
| Show source | F3 |
If the cursor is in the class name, pressing Shift-F2 will display the javadoc for the class. If the cursor in on a method name it will display the javadoc for that method. By default you will get the javadocs over the net from Sun. If you prefer a local copy or if you are using a third party jar in your classpath like Spring or Hibernate then you can specify where the javadocs are located. Find the appropriate jar in the Package explorer view. For the standard Java classes find rt.jar and right click on it and choose properties (or select rt.jar and press Alt-Enter). On the dialog that pops up you can specify the location of your local javadocs. You need to do this for each jar for which you want to associate javadoc locations.
You can also specify the location of the java source for this jar. The JDK ships with a file named src.zip. I learned Java back in 1995 from examining this zip since at that time there were no Java books. If you set this preference you can select a class name or mehod in your source, press F3 and go directly to the source! This is very convenient when you are learning a new API (Let's see how that Spring factory really works...)