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:

F3
Click on any variable name, class name, or method name, and press F3. This will bring you immediately to the place that that name is declared or defined, even if it is in a different .java file.
Ctrl-K
Select any text in the editor and this keystroke will bring you to the next occurrence of that text. Repeat as often as you like. You can set this search to wrap.
Alt-Shift-J
Generate a "skeleton" Javadoc comment. The mouse must be in the method definition or on the class name for this to work.
Ctrl-/
Add (or remove) // at the beginning of each line in the selection.
Ctrl-I
Correctly indents the selected lines. This command just indents--it doesn't correct bad spacing, or move anything from one line to another.
Ctrl-Shift-F
Reformat the selected lines, correcting indentation and spacing, and moving things from one line to another as necessary.

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:

Consolas and Menlo are some of the best fonts for programming; Courier or Courier New is generally OK. In Moore 207, I like bitstream vera sans mono at 10 point.

fonts

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.