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:
- Press Ctrl-T to increase line or block indentation.
- Press Ctrl-D to decrease line or block 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 fix formatting in code:
- Select the text you want to format. Do not select any text if you want
to format the entire file.
- 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:
- 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.
- In the Source Editor, click where you want to place the code and press
Ctrl-Shift-V.
To set indentation properties for Java files:
- Choose Tools > Options, click Editor, and select the Indentation tab.
- Set the indentation properties.
To set indentation properties for other types of files:
- Choose Tools > Options and click Advanced Options.
- 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.
- Set the indentation properties in the Properties pane of the Options window.
- You can use an indentation engine for different types of editors. For example,
you could use the simple indentation engine for Java files, or use the
line wrapping indentation engine for some file types. To assign an indentation
engine to an editor type, choose Tools > Options > Advanced Options > Editing > Editor Settings.
Then select the editor type and change the Indentation Engine property.
- See Also
- Setting Tab Behavior
- Configuring the Source Editor
- Setting Keyboard Shortcuts
Legal Notices