Eclipse is a very powerful IDE with a vast array of features, and it seems like I'm always stumbling on new ones. Here's a list of the Eclipse shortcuts I use the most often:
- Find any resource or type - Ctl + Alt + R will display a Search for Resource dialog - just start typing the name of the resource, and Eclipse will display a list of matching resources (handy for finding xml deployment descriptors when you're not sure where they're located). Ctl + Alt + T does the same thing, but is specific to Java types.
- Move a line of code up and down - Alt + UpArrow moves a line of code up. Alt + DownArrow moves it down. It will not overwrite existing lines of code above or below the current line, and you don't have to have the entire line selected. This also retains the code comment formatting/spacing, which is not retained when you manually cut and paste a code comment (thanks Juanita!)
- Copy a line(s) of code above or below - Ctl + Alt + UpArrow copies the currently selected line(s) above the current selection. Ctl + Alt + DownArrow copies the currently selected line(s) below the current selection.
- View all classes that implement an interface - select the interface and press Ctl + T to view a list of all classes that implement or extend the selected interface. Very handy when using frameworks like Spring or Tapestry that use interfaces instead of concrete classes.
- View all references to the selected construct - Ctl + G will display all references to the selected class, interface, method, or variable. Ctl + g will display all occurences of the selected construct. Very useful for finding all the places that a method or variable is being used.
- Drill down into a method or variable declaration - Click anywhere in the method or variable name, and press F3 to navigate to its definition. Press Alt + Left Arrow to navigate back.
- Organize import statements and remove unused imports - Press Ctl + Shift + O (works recursively if you select a project or folder).
- Close all windows - Press Ctl + Shift + F4 to close all editor windows - very useful when you have several files open for editing and want to quickly reduce the clutter.