Formatting Code

See Also

When you type a line of code in the Source Editor and press Enter, the new line is automatically indented according to the code hierarchy and the selected indentation engine. You can specify how you want your text formatted or disable automatic formatting by editing the indentation engine's properties.

To modify indentation on the current line:

To fix formatting in 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 pop-up menu.

    The selected code is formatted according to the rules of the indentation for that type of file. If no code is selected, the whole file is reformatted.

To automatically format code as you paste it into your file:

  1. Copy the text that you want to put into the Source Editor.

    The text can be copied from within the IDE or from different software.

  2. In the Source Editor, click where you want to place the code and press Ctrl-Shift-V.

To set indentation properties for Java files:

  1. Choose Tools > Options, click Editor, and select the Indentation tab.
  2. Set the indentation properties.

To set indentation properties for other types of files:

  1. Choose Tools > Options and click Advanced Options.
  2. Expand Editing > Indentation Engines and select the engine corresponding to the editor type. If there is no specific indentation engine for the editor type, select Simple Indentation Engine.
  3. Set the indentation properties in the Properties pane of the Options window.
See Also
Setting Tab Behavior
Configuring the Source Editor
Setting Keyboard Shortcuts

Legal Notices