Eclipse Tips
David Matuszek

Keyboard shortcuts

Some people like to learn all the keystroke "shortcuts," so they never have to take their hands from the keyboard. I'm not one of them. Research has consistently shown:

Nevertheless, there are some keystroke "shortcuts" that I think you should learn. Not only are they very useful, but some of them are buried in sub-menus that are not easy to find, so the keystrokes probably really are faster. Here they are, most important ones first:

Click on any variable name, class name, or method name, and press Function 3. This will bring you immediately to the place that that name is declared or defined, even if it is in a different .java file.
Select anything in the editor and this keystroke will bring you to the next occurrence of that thing. Repeat as often as you like. You can set this search to wrap.
Generate a "skeleton" Javadoc comment. The mouse must be in the method definition or on the class name for this to work.
Add (or remove) // at the beginning of each line in the selection.
Correctly indents the selected lines. This command just indents--it doesn't correct bad spacing, or move anything from one line to another.
Reformats the selected lines, correcting indentation and spacing, and moving things from one line to another as necessary. Formatting is done according to your preferences; you should use the default for Java programs by going to Project → Properties → Java Code Style → Formatter, clicking Configure workspace settings... (so it applies to all your projects, and choosing Java Conventions [built-in].

Choosing an editor font

Go to Window → Preferences... → General → Appearance → Colors and Fonts → Java → Java Editor Text Font and click Change....

Here's what you want in a font:

Courier or Courier New is generally OK. In Moore 207, I like bitstream vera sans mono at 10 point.

Typing support

Go to Window → Preferences... → Java → Editor → Typing and check everything. Then try some editing and see if you like the way it behaves. Give it a chance--don't reject it immediately just because it's different.

Hint: Some things, like putting semicolons at the end of a line, can be undone by hitting the backspace key.

Automatic file saves

When I run a program, I don't like always having to say yes, save the files first. To avoid this dialog box, go to Window → Preferences... → Run/Debug → Launching and under Save required dirty editors before launching, choose Always. Under General Options, check Build (if required) before launching.