Code Folding

Cold Folding collapses or "folds" the display of a block of code. Instead, the editor displays only the first line instead of the entire block. This reduces visual clutter by enabling users to selectively hide and display complicated text while still viewing those subsections of the text that are specifically relevant.

Cold Folding is enabled for classes, functions and PHPDocBlocks.

Enabling Code Folding

The default Code Folding preferences are set from: Windows > Preferences > PHP > Editor > Folding (see Setting Preferences).

  1. Place the cursor on the left Annotations Bar and right click. Select:
    Folding < Enable Folding
    from the drop down menu.

Using Code Folding

  1. To fold a block, click the minus sign. The first line of code will remain visible, the other lines will not be displayed; a fold indicator will appear at the end of the line when the code is folded.

Unfolded  

 

 

 

 

 

Folded

  1. To unfold a block, click the plus sign. The folded code will become visible again; the fold indicator will disappear.

  2. 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.
    Line numbers are folded together with the code. Folding and unfolding does not change line numbers, it can only hide / display them.
  3. If the folded code contains an error, the displayed window will be syntax highlighted on both the left and on the right Annotation bars.

Nested Code

  1. To fold nested functions, click on one of the minus signs. 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.

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

Scope

  1. Classes and Functions are marked from the end of the first line to the end of the last line that defines the class / function  (the line with the closing curly bracket) at that level.

  2. PHPDoc folds are marked from the end of the first line to the end of the last line that defines the doc (e.g., the  */  ).

  3. The range of an individual fold (at its specific level, when nested) is marked by a vertical line on the left Annotation bar, when hovering. Place the cursor on the minus sign that corresponds to a fold, then hover; a vertical line that marks the range of the fold will appear.