Articles

-What is a Text Editor?
-Large Files
-Encoding
-Syntax Highlighting
-Vertical Selection
-Snippets
-Macros
-Compare Documents
-Find and Replace
-Wrapping
-Code Folding
-Web Preview

-More Resources

Share |

What are Code Folding and Text Folding?

Also called expand and collapse, outlining, and code hiding, folding is a useful feature in text editing programs that allows you to hide or display sections of code or text. By folding sections of a document, you can reduce clutter in your document and just focus on the areas that are important at any given moment.

Essentially, folding creates an outline based on the document, and allows you to collapse levels of the outline when you want to.

Folding works by recognizing certain "folding points" within a document, which let the text editor know where to start and end a foldable segment. Most text editors allow you to customize what kinds of folding points you want recognized, though there are certain folding points that text editors include in their default settings.

One of the most popular folding point choices involves using delimiters. Similar to tags in programming and markup languages, delimiters define a beginning and ending of folding segments by enclosing them in braces, brackets, or similar symbols.

Level 1
{{{
Level 1 Content
}}}

Level 2
{{{
Level 2 Content
}}}

Indentation based folding uses the number of tabs or spaces preceding a line to determine its ranking in the folding outline.

Level 1
   Level 1 Content

Level 2
   Level 2 Content

For the formal syntax of programming and markup languages, some text editors offer a folding feature that recognizes specific content in a document to use as the basis for folding. This kind of folding in particular is associated with code folding.

You won't find folding among Notepad's limited arsenal of features, so be prepared to check out a more advanced text editor if you're looking for a program with folding capabilities.


© 2010 Text-Editor.org