Few weeks ago I wrote that I try to improve indentation engine and formatting for PHP files. Some improvements in the indentation engine were done during fixing NetBeans 6.8 and with this post I would like to start a discussion about formatting, which I try to improve during these days. In the development builds there are new categories for the PHP formatting options. Now are available categories for setting Tabs and Indents, Braces, Spaces and Blank Lines.
User can modify behavior of the formatter in two levels. In Editor category -> Formatting tab in Options dialog (Tools -> Options) you can modify setting for PHP formatting. You should select PHP in the Language combo box, if you want to change PHP specific settings.
These global options influence the behavior for all PHP files, except the files belonging projects that use their own setting. So the PHP formatting can be also influence on the project level. In Project Properties dialog is Formatting category and you can decide, whether the project will use global options or the project specific options. Also you can easily reuse options from other project after click on Load from other project button. Like in the global options you should select PHP in the Language combo box, if you want to change behavior of the PHP formatting for the selected project.
The first category is Tabs And Indents. The options Number of Spaces per Indent, Tab Size and Right Margin are common for all editors and by default the global setting is used. The check box Expand Tabs to Spaces is clear. By default it is checked and it means that the existing chars '\\t' are replaced by the count of spaces that is defined as Tab Size property. Property Number of Spaces per Indent defines the maximum number of spaces that will be created after pressing TAB key to indent the source code. When the check box Expand Tabs to Spaces is unchecked, then the defined number of spaces in Tab Size property is converted to the '\\t' char. For this reason is good if you set Number of Spaces per Tab to an even multiple or divisor
of Tab Size .
The PHP specific options:
It should be clear from this picture:
The next time I'm going to write about next category. Try the latest development build and suggest what else should be configurable.