Code folding is indention based since version 14.60. But you can influence the behavior. E.g. where the fold should start and where it should end. Some special symbols are allowed.
^ = can be preceded by white-space characters.
~ = can be preceded by words (alphanumeric characters).
~^ = can be used with Fold_End (Fold_End=~^<string>). See example below.
Fold_Id
Syntax
Fold_Id=<string>
Description
Start a fold block at a given string.
Example
We want to be able to fold a function and have the fold start at the declaration line.
Fold_Id=^function
Fold_Begin={
Fold_End=}
Fold_ListItem=ceMethod
The word "function" must be the first non white-space string found on the line. Otherwise it's not a function. It should also begin with { and end with a }.
The function will be listed in the code explorer as a method.
Fold_Begin / Fold_End
Syntax
Fold_Begin=<string>
Fold_End=<string>
Description
In several programming languages a block is marked by a begin id and an end id. These can be { ... } or begin ... end. The editor may use the begin and end id strings to correctly identify the start and end line of the fold.
Example
The syntax file for .ini files contain the following.
Fold_Id=^[
Fold_Begin=
Fold_End=~^[
Fold_Level=nltRegion
Fold_ListItem=ceMethod
An Ini file may look like this:
[section]
key1=value1
key2=value2
[section 2]
...
The top of each fold should start with [ and it must be the first non white-space character on the line. This will identify the section.
The end of the fold is more complicated. It should end above the next section, but not at a blank line. "Fold_End=~^[" does just that. It tells the editor to find [ as the first non white-space character and then backtrack "~" to the first non blank line above (which is the line "key2=value2").
The fold_level option value tells the editor to ignore indention and not to allow any nested folds. The section is listed in the code explorer as a method (could have used ceStruct or something else...).
Fold_Level
Syntax
Fold_Level=nltNone, nltFirst, nltNestedOnly, nltRegion, nltNestedRegion, nltRegionIndent, nltNestedRegionIndent
Description
This option will define the behavior of the fold or let the editor know where it is allowed.
nltNone
|
Default value. The fold is mostly based on indention.
|
nltFirst
|
The fold must not be inside another fold. It must be the top fold.
|
nltNestedOnly
|
The fold should always be inside another fold and never be the top fold.
|
nltRegion
|
Finds the Fold_Id and creates a fold to Fold_End. Nested folds are not allowed. Indention is ignored when creating the region.
|
nltRegionIndent
|
Finds the Fold_Id and creates a fold to Fold_End. Nested folds are not allowed. Indention is used to find the correct Fold_End.
|
nltNestedRegion
|
Finds the Fold_Id and creates a fold to Fold_End. Nested folds are allowed. Indention is ignored when creating the region.
|
nltNestedRegionIndent
|
Finds the Fold_Id and creates a fold to Fold_End. Nested folds are allowed. Indention is used to find the correct Fold_End.
|
nltSkip
|
Do not fold this.
|
Example
This is used in the Pascal syntax file to prevent a fold at the "interface" keyword. When the interface section keyword is found - that whole line is skipped and no fold is created.
Fold_Id=^interface
Fold_Begin=
Fold_End=
Fold_Level=nltSkip
Fold_ListItem=
Fold_ListItem
Syntax
Fold_ListItem=<string>
Description
Use this option to tell the editor that this fold should be added to the code explorer. The type can be:
<empty> or ceSkip
|
the fold will not be added to the code explorer. Use ceSkip with Fold_Level=nltNestedRegion/nltRegion.
|
ceStruct
|
structures, records...
|
ceEnum
|
enumerations
|
ceClass
|
class
|
ceNS
|
namespace (.NET)
|
ceMethod
|
procedure, functions...
|
ceConstructor
|
constructor
|
ceDestructor
|
destructor
|
ceProperty
|
property
|
ceTag
|
HTML tag
|
ceTagStyle
|
HTML style tag
|
ceTagScript
|
HTML script tag
|
ceTagHead
|
HTML head tag
|
ceTagBody
|
HTML body tag
|
ceUnknown
|
misc...
|
Example
To find a class in a C# file and make sure it's listed in the code explorer - we can use:
Fold_Id=~class
Fold_Begin={
Fold_End=}
Fold_Level=
Fold_ListItem=ceClass
|