teaching machines

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 with Control-Shift-O or Command-Shift-O. That’s the letter O, not the number 0.
  • Automatically reformat your code with Control-Shift-F or Command-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 or Command-A. Then hit Control-Shift-I or Command-Shift-I.
  • Comment or uncomment the line of code in which the cursor resides with Control-/ or Command-/. 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 or Command-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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *