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 and according to the selected indentation engine.

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.
Tip Use the properties of the indentation engine to specify how you want your text formatted, or to specify that you don't want any automatic formatting at all.

For the Java Indentation Engine, you can set properties to specify whether to add a leading star in lines within a block quote, 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.

For both the Java Indentation Engine and the Simple Indentation Engine, you can configure the number of spaces you want in a tab stop.

To set these options, choose Tools and choose Options and expand the Editing node. Then expand the Editor Settings node and select the desired editor type. You can set the desired indentation engine (Java, Simple, or none), and the properties of the indentation engine as described above.

See also
Configuring the Source Editor
Setting Keyboard Shortcuts
Source Editor Properties

Legal Notices