Eclipse Shortcuts
Eclipse has a lot of keyboard shortcuts and I know hardly any of them. But my students still think I’m an ace. These are the ones I do use on a regular basis, shared so that my students can be aces:
- Automatically add
import
statements to classes that live in faraway packages withControl-Shift-O
orCommand-Shift-O
. That’s the letterO
, not the number0
. - Automatically reformat your code with
Control-Shift-F
orCommand-Shift-F
. You don’t need to have the code highlighted for this to work. However, this will only work when there are no egregious syntax errors. - If you do have have egregious errors and still want to clean up your code’s indentation, first select your code with
Control-A
orCommand-A
. Then hitControl-Shift-I
orCommand-Shift-I
. - Comment or uncomment the line of code in which the cursor resides with
Control-/
orCommand-/
. To apply this to multiple lines, select them first. - Maximize (or unmaximize) the current editor with
Control-M
. - For some reason, Eclipse doesn’t have a human-friendly keyboard shortcut to just run the current program. I add
Control-R
orCommand-R
for this purpose by visiting the Eclipse preferences, navigating to General / Keys, searching for and selecting the Run command, and typing the new shortcut in the Binding textbox.