Formatting Code

When you type a line of code in the Source Editor and press Enter, the next line is automatically indented according to the hierarchy in the code.

To modify indentation:

In both cases, if nothing is selected, the current line is shifted one tab stop. If a block of text is selected, all those lines are shifted.

To automatically format code:

  1. Select the text you want to format. Do not select any text if you want to format the entire file.

  2. Press Ctrl-Shift-F or right-click in the Source Editor and choose Reformat Code from the contextual menu.

You can set properties to specify whether a space is added before an opening parenthesis and whether an opening curly brace is placed on a new line whenever text is generated or reformatted by the IDE. You can also configure the number of spaces you want in a tab stop. Set these options by choosing Tools Options and then selecting the Java Editor subnode of Editor Settings.

See also Configuring the Source Editor

Setting Keyboard Shortcuts

Java Editor Properties
Legal Notices