Code folding is a feature of some text editors that allows the selective hiding and displaying of the text being edited. This is particularly useful if you are working on a small subsection of a large, complicated text. Code folding allows you to display and work on the relevant portion of the text while hiding the rest. It also allows you to view the structure of the text by hiding irrelevant details. While primarily a feature of programmer’s editors and IDEs, it is easy to see how this feature can be useful to writers as well.
There are a variety of ways to implement code folding. Sometimes special delimiters are used to mark where in the text the fold is to occur; other times the folding is syntax-based. If the implementation of code folding is syntax-based, then this feature will only be useful for writing if you are using some form of structural markup such as LaTeX or DocBook.
Developed in the 70s in the Lisp community, code folding editors are the ancestor of outliners, such as OmniOutliner and TAO. (For some of the hitory of outliners see Outliners.com, Dave Winer’s history of More and Ted Goranson’s column About This Particular Outliner.) The expanding and collapsing file system viewer that first appeared in MacIntosh System 7 was an abstraction of the code folding UI, an abstraction that informs the UI of a variety of programs today.
As I posted earlier, BBEdit 8.7 features improved code folding. Following on the heals of this, TextMate revision 1413 offers a small refinement to its folding GUI:
[CHANGED] The right-pointing folding arrow is another color to make it visually distinct from the up/down arrows. Thanks to Paul Howson.
The visual distinction is a nice detail. Not everyone, however, was thrilled with the implementation:

It’s not just that the orange is garish (it is), but it is sufficiently loud to drown out the gray down arrow. Thomas Aylott of subtleGradient, benevolent soul that he is, has answered the howls of protest on the mailing list with a customized nib and png files that provided a more muted contrasting gray for the right arrow. The results can be viewed here and the files can be downloaded here. Thanks, Thomas, for teh awesomeness!
{ 2 } Comments
I thought TextMate would only fold blocks of text that had clear start and end markers, and therefore that it could not form the main LaTeX sectioning commands like section, subsection, subsubsection, etc.. At least it doesn’t let you fold these sections when you create a LaTeX file from its default template.
Have you made custom changes to your TextMate configuration?
Thanks for making so much information available on your site. It’s been a great help to me in choosing the right tools as I write up my dissertation.
Tab triggers are snippets of text that are inserted by typing some predetermined text and hitting tab. If you insert the sections (and subsections etc) using the tab triggers in the LaTeX bundle, i.e., typing “sec” and hitting tab, you get the following:
section{section name}label{sec:section_name} % (fold)
% section section_name (end)
The comments (“% (fold)”, “% section section_name (end)”) function as fold markers thus allowing code folding of sections. This is a standard part of the LaTeX bundle. Just be sure to insert your sections with the provided snippets. (It is quicker anyway.)
Post a Comment