Using Code Folding

Code Folding collapses or "folds" the display of a block of code.

To enable code folding, go to the Folding Preferences page, accessible from Window | Preferences | PHP | Editor | Code Folding .

If Code Folding is enabled, minus signs will appear in the Annotation Bar next to code blocks which can be folded. In addition, certain elements will be folded by default according to the Folding Preferences settings.

Folding a Block of Code

 

 

Instructions on how to complete a procedure

To fold a block of code:

  1. Stand within a class, function or PHPDocBlock.

  2. Click the minus sign on the marker bar to the left of the editor.

The first line of code will remain visible but the other lines will not be displayed. A fold indicator will appear at the end of the line when the code is folded to indicate that there is hidden code.

To temporarily view folded code, hover over the plus sign that denotes a folded block. The folded code will be displayed in a floating block.

Unfolding a Block of Code

 

 

Instructions on how to complete a procedure

To unfold a block of code:

  1. Click the plus sign.

  2. The folded code will become visible again and the fold indicator will disappear.

To view the scope of a fold:

  1. Hover over the minus sign.

  2. A vertical line will be displayed from the first to the last line of the fold, indicating its range.

 

An unfolded function

A folded function

Folding/Unfolding Nested Functions

Instructions on how to complete a procedure

To fold/unfold nested functions:

  1. Click on one of the minus signs of a nested function. All levels below this level will be folded into it. You can continue to fold until all levels have been folded into the topmost level.

  2. To unfold nested functions, click on the plus sign. The folded code will open in the same order that it was folded.

 

 

Instructions on how to complete a procedure

To fold/unfold all code within a file:

  1. Place your cursor within the file.

  2. If code folding is not available (no plus or minus signs are displayed in the marker bar), click Ctrl+Numpad_Divide.

  3. Click Ctrl+Numpad_Multiply to Expand All folds or Ctrl+Numpad_Divide to Collapse All folds.

 

Note:

Line numbers are folded together with the code. Folding and unfolding does not change line numbers, it can only hide/display them.

Note:

If the folded code contains an error, the displayed window will be syntax highlighted on both the left and right Annotation bars.