Code or text folding, or less commonly holophrasting,[1] is a feature of some graphical user interfaces that allows the user to selectively hide ("fold") or display ("unfold") parts of a document. This allows the user to manage large amounts of text while viewing only those subsections that are currently of interest. It is typically used with documents which have a natural tree structure consisting of nested elements. Other names for these features include expand and collapse, code hiding, and outlining. In Microsoft Word, the feature is called "collapsible outlining".
Many user interfaces provide disclosure widgets for code folding in a sidebar, indicated for example by a triangle that points sideways (if collapsed) or down (if expanded), or by a [-]
box for collapsible (expanded) text, and a [+]
box for expandable (collapsed) text.
Code folding is found in text editors, source code editors, and IDEs. The folding structure typically follows the syntax tree of the program defined by the computer language. It may also be defined by levels of indentation, or be specified explicitly using an in-band marker (saved as part of the source code) or out-of-band.
Text folding is a similar feature used on ordinary text, where the nested elements consist of paragraphs, sections, or outline levels. Programs offering this include folding editors, outliners, and some word processors.
Data folding is found in some hex editors and is used to structure a binary file or hide inaccessible data sections.[2]
Folding is also frequently used in data comparison, to select one version or another, or only the differences.