Formatting Files or Portions of Code

1.

Open a Java Editor on the Java file whose source code you want to format (either partially or completely).

2.

Select the region of the code you want to format. If nothing is selected, then all of the editor content is formatted.

3.

From the context menu in the editor, select Format.

4.

The code is formatted according to your indicated preferences (Window > Preferences > Java > Code Formatter).