IDE Window: Editor Options Code Folding

From Free Pascal wiki
Revision as of 00:24, 20 August 2009 by Martin (talk | contribs) (Language specific options)
  • You can get this dialog via:
Menu / Environment / Editor options / Code folding
Source editor / popup menu / Options ...


Code folding allows certain structure or blocks of text to be "collapsed". This will hide all but the first line of the block, and the first line will be marked with the folded-symbol "[...]" at the end of that line.

Code folding is done by using a special area in the Gutter which displays the code folding tree. In the tree you will find nodes at the lines were a fold-able region starts.

  • [-] denotes the beginning of a fold-able block, which is not yet folded. This is called an expanded block. Clicking on the [-] Symbol will fold (collapse) this block.
  • [+] denotes the beginning of a fold-able block, which is folded (hidden). This is called an collapsed block. Clicking on the [+] symbol will unfold (expand) this block.
  • | a vertical line is shown in front of lines that belong to a fold-able region, but are not the top line of such a region. The vertical line always begins under the [+] sign and continues to the last line of the block. On the last line it displays a tiny edge.

Fold-able blocks can be nested or overlapped.


Code folding

The checkbox on top globally enables or disables code folding. If disabled, the Gutter will not display the fold tree neither.

Language specific options

Currently code folding is only supported for Pascal Source

Select (tick) the structures you like to be fold-able

Entire procedures or functions
Var/Type (local)
Any var, type or const declaration block that is local to a procedure
Begin/End (procedure)
The begin-end block of a procedure or function. This is the most outer block only, which encloses the entire procedure
Begin/End (nested)
Any other begin-end block.
Any entire Try-finally/except-end block
Allows to fold the code between the Except of finally keyword, up to the "end" of the entire "try" block
The entire code up to the "end." statement. (this is for "program" files not for units)
The entire unit up to the "end."
unit section
Any interface, implementation, initialization or finalization block
If your uses clause goes over more than one line.
Var/Type (globa;)
Any var, type or const declaration block (except for the ones local in a procedure)
Nested comments
Allows to define your own blocks, by putting this special comment into the code. ends with {%Endregion}


Using the Mouse

Using the Context Menu

Using Keyboard