Home » Support » Tutorials/Power Tips » UltraEdit » Code Folding

IDM PowerTips

Code Folding

Code folding is indispensable for managing complex/nested code structures. Code folding allows you to collapse (hide) a section of code. The collapsible sections are based on the structure of the file/language.

How does code folding work?

Code folding uses the hide/show lines feature to collapse sections of code.

To collapse a section of code, click the - (minus) symbol. Conversely, to expand a section of code, click on the + (plus) symbol.

Code Folding

Configuring code folding

Code folding is on/enabled by default. But, if you need to, you can enable code folding in Advanced : Configuration : Editor Display : Code Folding. There are two options relating to code folding, check (enable) the "Enable show/hide lines and code folding" and (if you prefer) "Enable show/hide lines in non syntax highlighted files".

Code Folding

Graphical lines

As of UltraEdit v16.10, UltraEdit displays a dashed visual fold line:

Code Folding

Additionally, the active fold line changes color when you place your cursor next to an open/close fold section.

Code Folding

You can enable this feature by checking the "Draw graphical lines" option in Advanced : Configuration : Editor Display : Code Folding.

Code Folding

Advanced code folding configuration

UltraEdit/UEStudio's code folding is based on unique open/close strings. UltraEdit has defaults for Open and Close Fold Strings for many languages. If no strings are specified in the wordfile, the defaults are used.

The default open braces are "{" "If" "ElseIf" and corresponding close braces are "}" "ElseIf" "End If". Of course, you can also define which open/close fold strings to use.

The open/close strings are defined in the wordfile on a per language basis. You can find the wordfile in Advanced : Configuration : Editor Display : Syntax Highlighting.

Code Folding

To edit the open/close fold strings, select the appropriate language and click the Open button.

The open/close brace strings are defined as follows:

Correct example:

/Open Fold Strings = "{" "If" "ElseIf"
/Close Fold Strings = "}" "ElseIf" "End If"

Save and close the file when you have finished modifying your open/close fold strings.