User Guide > Tasks > Formatting Code

Formatting Code

Zend Studio can auto-format your code according to set standards in order to make it easily navigable and readable.

Your code will be automatically formatted according to the settings defined in the PHP Formatter Preferences page, accessed from Window | Preferences | PHP Formatter.

This procedure demonstrates how to format your scripts.

Formatting Your Whole Script

 

 

Instructions on how to complete a procedure

To format your whole script:

  1. Open the required file.

  2. Go to Source | Format Document or press Ctrl+Shift+F.

Your code will be automatically formatted.

 

 

Usage Example

Example:

Unformatted Code

Formatted Code

Formatting Selected Lines within the Script

 

 

Instructions on how to complete a procedure

To format only selected lines within the script:

  1. Select the relevant lines.

  2. Go to Source | Format Active Elements -or- press Ctrl+I.

Only the selected lines will be formatted.

Note:

Code Formatting will also be available in JavaScript editors.
JavaScript Formatting preferences can be configured from Window | Preferences | Web | JavaScript | Code Style | Formatter.

 

 

Related Links:

Formatter Preferences

 

 

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