User Guide > Reference > PHP Preferences > Formatter Preferences

Formatter Preferences

Zend Studio can auto-format scripts to organize them into an easily readable format. The Formatter Preferences page allows you to customize the way it is formatted.

The Formatter Preferences Preferences page is accessed from Window | Preferences | PHP | Code Style | Formatter.

Creating Your Own Set of Configuration Settings

The default formatting settings are based on the PHP Conventions settings.

Click Show to see these settings.

 

 

Instructions on how to complete a procedure

To create your own set of configuration settings:

  1. Click New.

  2. Enter a name for you profile.

  3. Select which profile to base your new profile on. (This will duplicate these settings and allow you to edit them).

  4. Ensure that the 'Open the edit dialog now' checkbox is marked and click OK.

  5. The Edit dialog will open with the following tabbed option screens:

  • Indentation

  • Braces

  • White Space

  • Blank Lines

  • New Lines

  • Control Statements

  • Line Wrapping

These are described in more detail below.

  1. Once you have set the required options, click OK.

 The new configuration will be added to the list.

 

The Options Available in the Formatter Tabs

These options are available by clicking Show in the Formatter Preferences page.

Indentation

The Indentation tab allows you to configure the indentation size and select which elements should be indented.

The Indentation tab contains the following options:

General Settings

Indent

Select the elements to be indented by marking the relevant checkbox from the following options:

Braces

The Braces tab allows you to configure brace positions.

Choose the brace positions (Same line, Next line or Next line indented) for the following:

White Space

The White Space tab allows you to configure where spaces should be entered for declarations, control statements, expressions and arrays.

Expand each category by clicking on the + sign to configure which items are applied

to each instruction.

 

Standing on an item will display a list of possible syntax conditions in which white

spaces will be inserted. Select the required conditions by marking the relevant checkboxes.

 

Choosing 'sort options by Syntax element' from the drop down list will sort the list

of by syntax conditions rather than by element.

 

Blank Lines

The Blank Lines tab allows you to set the number of blank lines to be created in various conditions.

Enter the number of blank lines (between 0-32) to be created in the following conditions:

Blank Lines

Existing Blank Lines

New Lines

The New Lines tab allows you to select when new lines will be created.

The Options in the New Lines tab

Insert New Line

Select whether to insert a new line in the following conditions:

Array Initializers

Select whether to:

Empty statements

Select whether to put empty statements on a new line.

Control Statements

The Control Statements tab allows you to configure the line formatting for Control Statements.

The Control Statements tab contains the following options:

General

'if else'

Line Wrapping

The Line Wrapping tab allows you to configure Line Wrapping properties.

The Line Wrapping tab contains the following options:

Line Width and Indentation Levels

Line Wrapping and Indentation Policies

To set line wrapping and indentation wrapping policies for a specific element, select an element from the collapsible list and select an option from the 'Line wrapping policy' and 'Indentation policy' drop-down lists.

The elements for which the line and indentation policies can be applied are :

Comments

The Comments tab allows you to configure line comment formatting.

Off/On Tags

The Off/On Tags tab allows you to enable the Off/On tags. Off/On tags can be used in any comments to turn the formatter off and on in a source file.

Importing an Existing Formatting Configuration

 

 

Instructions on how to complete a procedure

To import an existing formatting configuration:

  1. Click Import.

  2. Select an XML file with the required configuration settings.

  3. Click OK.

The new configuration will be added to the list.

Exporting a Configuration File to an XML File

 

 

Instructions on how to complete a procedure

To export a configuration file to an XML file:

  1. Select the required configuration from the drop-down list.

  2. Enter a name and location for the file.

  3. Click OK.

  4. An XML file will be created with the required settings.

 

Formatter Preferences page

Applying Formatter Preferences Settings to a Specific Project

 

 

Instructions on how to complete a procedure

To apply Formatter Preferences settings to a specific project only:

  1. Select the link labelled "Configure Project Specific Settings".

  2. Select the required project from the list.
    A Formatter Preferences Properties dialog will appear.

  3. Select the required settings and click Apply.
    A prompt dialog will appear stating that a rebuild of the project must occur for the settings to take effect.

  4. Click Yes to rebuild the project.
    -Or- Click No for a rebuild to be performed only when Zend Studio is restarted.
    -Or- Click Cancel to cancel the operation.

 

 

 

Related Links:

Formatting Code

PHP Preferences

 

 

©1999-2013 Zend Technologies LTD. All rights reserved.