This page describes the options in both Options: Editor: Formatting and Project Properties: Formatting if you select the PHP language. Options: Editor: Formatting sets global options
whereas Project Properties: Formatting sets project-specific options.
The Preview Window
The Preview window contains sample code that reflects changes you make in Formatting.
Use All Languages Settings. Unselect to override the
All Languages settings. Unselecting Use All Languages Settings enables the following fields:
Expand Tabs to Spaces. When selected, inserts spaces when the Tab key is typed.
When unselected, typing the Tab key inserts the tab character (\t) into the file if
possible. It also replaces preceding spaces with the tab character if possible.
The Source Editor calculates where to place tab characters based on the value
of the Tab Size property.
If Expand Tabs to Spaces is unselected and the Number of Spaces per Indent is different
than the Tab Size property, the indentation created by typing the Tab key is
made up of a combination of spaces and tab characters. It is easiest to predict
the location of tab characters if you set Number of Spaces per Indent to an even
multiple or divisor of Tab Size.
Important: This feature does not convert
existing tabs to spaces. Only tabs that you add after you
enable this option are converted.
Indent: Number of spaces per indentation level for subelements, new lines inside
brackets, etc.
Tab size:See the description of Expand Tabs to Spaces, above.
Right margin: Position of the vertical red line that indicates the right margin.
Line wrap: Whether lines are wrapped when they are longer than the width of the Editor window (no relationship to right margin). Options are:
Off. No line wrapping (default).
After words. Words are not broken by line wrapping.
Anywhere. Lines are broken in the middle of words by line wrapping.
Initial Indentation: Indentation of the first line of
the PHP code block, after the initial <? tag.
Continuation Indentation: If you place a line break in a code statement, this is how
far the IDE indents the continuation of the code statement after the line break.
Array Declaration Indentation. If you place a line break in an array declaration,
this is how far the IDE indents the continuation of the array declaration after the line break.
You can experiment with different Tab and Indent settings and see the results in the Preview window.
Alignment
Specify which elements should be aligned after a line break.
New lines. The IDE breaks lines before any elements you select here.
Group Multiline Alignment. Aligns the selected character
horizontally across all
lines in a group. A group is defined as a number of lines that
contain the same type of assignments. The group can be terminated
by an empty line, a line with only a comment, a different expression,
or the end of a block. For more information, see the
Assignment. Affects position of the equal sign
character = in a
group of lines with assignments. When you set this to 'on',
the assignment char '=' is aligned after the longest identifier in a group.
This formatting option works for variable assignments,
field initializations, and constants.
Array Initializer. Affects position of the initializer characters => in a group of lines.
Multiline Alignment. Use if you set lines to wrap automatically at an element and
you want that element to be aligned vertically. First turn wrapping on
for the element and then select the element in this dialog.
Requires Wrapping to be turned on for the same element.
You can experiment with different Alignment settings and see the results in the Preview window.
You can only preview Multiline Alignment for an element if you have turned Wrapping on for the same element.
Braces
Select where to place the braces for each type of statement listed in this dialog. Use the Format
function (Alt+Shift+F) to apply the Braces settings to a PHP document.
The possible brace locations are:
Same line
New line
New line indented
Preserve existing
You can experiment with different Braces settings and see the results in the Preview window.
Blank Lines
Improves readability by setting off sections of code that are logically related according to the specified options. Select the number of blank lines to place in the listed positions. For example, "After Fields:
1" places 1 blank line after every field.
You also have the option to Group Fields Without PHP Doc. This is selected by default. When
you select this option, there are no blank lines between fields that do not have PHPDoc documentation.
You can experiment with different Blank Lines settings and see the results in the Preview window.
Spaces
In this panel, set where the IDE automatically puts whitespaces. Due to the large number
of possible places to put whitespaces, the places to put whitespaces are displayed in a tree
of categories.
Expand a tree node to see the places under a category, or
collapse a node to hide the places under a category. The categories are:
Before Keywords (example: "while")
Before Parentheses (example: "for (")
Around Operators (example: binary operators)
Before Left Braces (example: Class declarations, "class Example {")
Within Parentheses (example: "if ( convert...")
Other (example: After Commas)
You can experiment with different Spaces settings and see the results in the Preview window.
Wrapping
In this panel set the rules for the IDE to wrap lines automatically. The panel lists the
possible elements before which the IDE wraps lines. For each element you can have the IDE never
wrap lines, always wrap lines, or wrap lines if the statement is long (wider than the Editor window).
You can also have the IDE automatically wrap lines after opening and before closing block
braces, and between statements that are typed on the same line. Both of these options are enabled
by default.
You can experiment with different Wrapping settings and see the results in the Preview window.