<s>
Code	O
or	O
text	B-Application
folding	I-Application
,	O
or	O
less	O
commonly	O
holophrasting	B-Application
,	O
is	O
a	O
feature	O
of	O
some	O
graphical	B-Application
user	I-Application
interfaces	I-Application
that	O
allows	O
the	O
user	O
to	O
selectively	O
hide	O
(	O
"	O
fold	O
"	O
)	O
or	O
display	O
(	O
"	O
unfold	O
"	O
)	O
parts	O
of	O
a	O
document	O
.	O
</s>
<s>
It	O
is	O
typically	O
used	O
with	O
documents	O
which	O
have	O
a	O
natural	O
tree	B-Data_Structure
structure	I-Data_Structure
consisting	O
of	O
nested	O
elements	O
.	O
</s>
<s>
Other	O
names	O
for	O
these	O
features	O
include	O
expand	B-Application
and	I-Application
collapse	I-Application
,	O
code	B-Application
hiding	I-Application
,	O
and	O
outlining	O
.	O
</s>
<s>
In	O
Microsoft	B-Application
Word	I-Application
,	O
the	O
feature	O
is	O
called	O
"	O
collapsible	O
outlining	O
"	O
.	O
</s>
<s>
Many	O
user	O
interfaces	O
provide	O
disclosure	B-General_Concept
widgets	O
for	O
code	B-Application
folding	I-Application
in	O
a	O
sidebar	O
,	O
indicated	O
for	O
example	O
by	O
a	O
triangle	O
that	O
points	O
sideways	O
(	O
if	O
collapsed	O
)	O
or	O
down	O
(	O
if	O
expanded	O
)	O
,	O
or	O
by	O
a	O
 [ - ] 	O
box	O
for	O
collapsible	O
(	O
expanded	O
)	O
text	O
,	O
and	O
a	O
 [ + ] 	O
box	O
for	O
expandable	O
(	O
collapsed	O
)	O
text	O
.	O
</s>
<s>
Code	B-Application
folding	I-Application
is	O
found	O
in	O
text	B-Application
editors	I-Application
,	O
source	B-Application
code	I-Application
editors	I-Application
,	O
and	O
IDEs	O
.	O
</s>
<s>
The	O
folding	O
structure	O
typically	O
follows	O
the	O
syntax	B-Data_Structure
tree	I-Data_Structure
of	O
the	O
program	O
defined	O
by	O
the	O
computer	B-Language
language	I-Language
.	O
</s>
<s>
Text	B-Application
folding	I-Application
is	O
a	O
similar	O
feature	O
used	O
on	O
ordinary	O
text	O
,	O
where	O
the	O
nested	O
elements	O
consist	O
of	O
paragraphs	O
,	O
sections	O
,	O
or	O
outline	O
levels	O
.	O
</s>
<s>
Programs	O
offering	O
this	O
include	O
folding	O
editors	O
,	O
outliners	B-Application
,	O
and	O
some	O
word	B-General_Concept
processors	I-General_Concept
.	O
</s>
<s>
Data	O
folding	O
is	O
found	O
in	O
some	O
hex	B-Application
editors	I-Application
and	O
is	O
used	O
to	O
structure	O
a	O
binary	O
file	O
or	O
hide	O
inaccessible	O
data	O
sections	O
.	O
</s>
<s>
Folding	O
is	O
also	O
frequently	O
used	O
in	O
data	B-Application
comparison	I-Application
,	O
to	O
select	O
one	O
version	O
or	O
another	O
,	O
or	O
only	O
the	O
differences	O
.	O
</s>
<s>
The	O
earliest	O
known	O
example	O
of	O
code	B-Application
folding	I-Application
in	O
an	O
editor	O
is	O
in	O
NLS	O
(	O
computer	O
system	O
)	O
.	O
</s>
<s>
Probably	O
the	O
first	O
widely	O
available	O
folding	O
editor	O
was	O
the	O
1974	O
Structured	B-Operating_System
Programming	I-Operating_System
Facility	I-Operating_System
(	O
SPF	O
)	O
editor	O
for	O
IBM	B-Device
370	I-Device
mainframes	O
,	O
which	O
could	O
hide	O
lines	O
based	O
on	O
their	O
indentation	O
.	O
</s>
<s>
It	O
was	O
very	O
useful	O
for	O
prolix	O
languages	O
like	O
COBOL	B-Application
.	O
</s>
<s>
It	O
evolved	O
into	O
the	O
Interactive	B-Operating_System
System	I-Operating_System
Productivity	I-Operating_System
Facility	I-Operating_System
(	O
ISPF	B-Operating_System
)	O
.	O
</s>
<s>
Code	B-Application
folding	I-Application
has	O
various	O
use	O
patterns	O
,	O
primarily	O
organizing	O
code	O
or	O
hiding	O
less	O
useful	O
information	O
so	O
one	O
can	O
focus	O
on	O
more	O
important	O
information	O
.	O
</s>
<s>
Most	O
basically	O
,	O
applications	O
use	O
code	B-Application
folding	I-Application
to	O
outline	O
source	O
code	O
,	O
collapsing	O
each	O
block	O
to	O
a	O
single	O
line	O
.	O
</s>
<s>
Documentation	O
with	O
Javadoc	B-Language
expands	O
this	O
to	O
20	O
lines	O
:	O
</s>
<s>
If	O
there	O
are	O
many	O
such	O
fields	O
,	O
the	O
result	O
can	O
easily	O
be	O
hundreds	O
of	O
lines	O
of	O
code	O
with	O
very	O
little	O
"	O
interesting	O
"	O
content	O
–	O
code	B-Application
folding	I-Application
can	O
reduce	O
this	O
to	O
a	O
single	O
line	O
per	O
field	O
,	O
or	O
even	O
to	O
a	O
single	O
line	O
for	O
all	O
fields	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
long	O
list	O
of	O
attributes	B-General_Concept
in	O
C#	B-Application
may	O
be	O
manually	O
collapsed	O
as	O
follows	O
:	O
</s>
<s>
This	O
can	O
be	O
the	O
case	O
either	O
for	O
a	O
long	O
comment	O
for	O
a	O
short	O
section	O
of	O
code	O
,	O
such	O
as	O
a	O
paragraph	O
to	O
explain	O
one	O
line	O
,	O
or	O
comments	O
for	O
documentation	B-Protocol
generators	I-Protocol
,	O
such	O
as	O
Javadoc	B-Language
or	O
.	O
</s>
<s>
Code	B-Application
folding	I-Application
allows	O
one	O
to	O
have	O
long	O
comments	O
,	O
but	O
to	O
display	O
them	O
only	O
when	O
required	O
.	O
</s>
<s>
In	O
cases	O
where	O
a	O
long	O
comment	O
has	O
a	O
single	O
summary	O
line	O
,	O
such	O
as	O
Python	B-Language
docstrings	O
,	O
the	O
summary	O
can	O
still	O
be	O
displayed	O
when	O
the	O
section	O
is	O
collapsed	O
,	O
allowing	O
a	O
summary/detailed	O
view	O
.	O
</s>
<s>
Structured	B-Language
programming	I-Language
consists	O
of	O
nested	O
blocks	O
of	O
code	O
,	O
and	O
long	O
blocks	O
of	O
code	O
–	O
such	O
as	O
long	O
switch	O
statements	O
–	O
can	O
obscure	O
the	O
overall	O
structure	O
.	O
</s>
<s>
Code	B-Application
folding	I-Application
allows	O
one	O
to	O
see	O
the	O
overall	O
structure	O
and	O
expand	O
to	O
a	O
specific	O
level	O
.	O
</s>
<s>
Further	O
,	O
in	O
some	O
uses	O
,	O
particularly	O
strict	O
structured	B-Language
programming	I-Language
(	O
single	O
function	O
exit	O
)	O
,	O
there	O
are	O
code	O
patterns	O
that	O
are	O
hard	O
to	O
see	O
when	O
looking	O
at	O
expanded	O
code	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
resource	O
management	O
in	O
structured	B-Language
programming	I-Language
,	O
one	O
generally	O
acquires	O
a	O
resource	O
,	O
followed	O
by	O
a	O
block	O
of	O
code	O
using	O
the	O
resource	O
,	O
and	O
finishing	O
with	O
releasing	O
the	O
resource	O
.	O
</s>
<s>
In	O
order	O
to	O
support	O
code	B-Application
folding	I-Application
,	O
the	O
text	B-Application
editor	I-Application
must	O
provide	O
a	O
mechanism	O
for	O
identifying	O
"	O
folding	O
points	O
"	O
within	O
a	O
text	O
file	O
.	O
</s>
<s>
Some	O
text	B-Application
editors	I-Application
provide	O
this	O
mechanism	O
automatically	O
,	O
while	O
others	O
provide	O
defaults	O
that	O
can	O
either	O
be	O
overridden	O
or	O
augmented	O
by	O
the	O
user	O
.	O
</s>
<s>
Each	O
of	O
these	O
has	O
its	O
own	O
distinct	O
advantages	O
and	O
difficulties	O
,	O
and	O
it	O
is	O
essentially	O
up	O
to	O
the	O
developers	O
who	O
create	O
the	O
text	B-Application
editor	I-Application
software	O
to	O
decide	O
which	O
to	O
implement	O
.	O
</s>
<s>
Text	B-Application
editors	I-Application
that	O
provide	O
support	O
for	O
multiple	O
folding	O
mechanisms	O
typically	O
allow	O
the	O
user	O
to	O
choose	O
which	O
is	O
most	O
appropriate	O
for	O
the	O
file	O
being	O
edited	O
.	O
</s>
<s>
This	O
is	O
most	O
often	O
used	O
as	O
a	O
simple	O
form	O
of	O
syntax-based	O
folding	O
,	O
as	O
indentation	O
almost	O
always	O
reflects	O
nesting	O
level	O
in	O
indent	O
styles	O
for	O
structured	B-Language
programming	I-Language
languages	O
.	O
</s>
<s>
This	O
convention	O
is	O
particularly	O
suitable	O
to	O
syntaxes	O
that	O
have	O
an	O
off-side	B-Language
rule	I-Language
,	O
so	O
the	O
structure	O
largely	O
agrees	O
with	O
the	O
indent	O
.	O
</s>
<s>
Examples	O
include	O
Python	B-Language
and	O
text	O
files	O
that	O
require	O
indentation	O
as	O
a	O
rule	O
by	O
themselves	O
.	O
</s>
<s>
Token-based	O
folding	O
points	O
are	O
specified	O
using	O
special	O
delimiters	B-Algorithm
that	O
serve	O
no	O
other	O
purpose	O
in	O
the	O
text	O
than	O
to	O
identify	O
the	O
boundaries	O
of	O
folding	O
points	O
.	O
</s>
<s>
The	O
most	O
common	O
delimiter	B-Algorithm
tokens	O
are	O
{{{	O
to	O
begin	O
the	O
folded	O
section	O
,	O
and	O
}}}	O
to	O
end	O
it	O
.	O
</s>
<s>
Another	O
notable	O
token	O
is	O
#region	O
(	O
)	O
,	O
respectively	O
#Region	O
(	O
)	O
,	O
used	O
in	O
Microsoft	B-Language
Visual	I-Language
Studio	I-Language
Code	I-Language
Editor	O
.	O
</s>
<s>
One	O
of	O
the	O
earliest	O
folding	O
editors	O
was	O
STET	B-Application
,	O
an	O
editor	O
written	O
for	O
the	O
VM/CMS	B-Application
operating	O
system	O
in	O
1977	O
by	O
Mike	O
Cowlishaw	O
.	O
</s>
<s>
STET	B-Application
is	O
a	O
text	B-Application
editor	I-Application
(	O
for	O
documentation	O
,	O
programs	O
,	O
etc	O
.	O
)	O
</s>
<s>
A	O
folding	O
editor	O
appeared	O
in	O
the	O
occam	B-Language
IDE	B-Application
circa	O
1983	O
,	O
which	O
was	O
called	O
the	O
Inmos	O
Transputer	O
Development	O
System	O
(	O
TDS	O
)	O
,	O
.	O
</s>
<s>
The	O
Macintosh	B-Device
computer	I-Device
historically	O
had	O
a	O
number	O
of	O
source	B-Application
code	I-Application
editors	I-Application
that	O
"	O
folded	O
"	O
portions	O
of	O
code	O
via	O
"	O
disclosure	B-General_Concept
triangles	O
"	O
.	O
</s>
<s>
Folding	O
is	O
provided	O
by	O
many	O
modern	O
text	B-Application
editors	I-Application
,	O
and	O
syntax-based	O
or	O
semantics-based	O
folding	O
is	O
now	O
a	O
component	O
of	O
many	O
software	B-Application
development	I-Application
environments	I-Application
.	O
</s>
