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
importstatements to classes that live in faraway packages withControl-Shift-OorCommand-Shift-O. That’s the letterO, not the number0. - Automatically reformat your code with
Control-Shift-ForCommand-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-AorCommand-A. Then hitControl-Shift-IorCommand-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-RorCommand-Rfor 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.