Jed35
2.3.3Folding Code
The ability to fold buffers in order to view only the parts of a file that are necessary at the
time is quite useful when trying to understand program flow and how the application is put
together at a very high level.
In order for folding to be used, special markers must be put in the file at the appropriate
points. There are two markers, one to denote the beginning of a section to be folded and one to
denote the end. In plain text files, these markers must be in the leftmost column; but when an
application language that is recognized by Jed is used, they may be inserted in comments.
The opening marker is three left curly braces “{{{” and the closing is three of the right
“}}}” To insert marker into a C-language program, place the markers directly after the /* that
begins the comment:
/*{{{ Deep magic begins here. */
{
x = n[i];
a = ((a<<19)^(a>>13)) + n[(i+128)&255];
n[i] = y = n[x&255] + a + b;
r[i] = d = n[(y>>8)&255] + x;
}
/*}}} */
When the file is folded up, the above section of code will appear as follows:
/*{{{ Deep magic begins here. */...
The ellipsis at the end of the line indicates that this line may be unfolded.
Figure 2-9 shows a section of Perl code with the fold markers in place. The comments are
placed before and after each section of code and a description of the code included in that fold
has been added. Figure 2-10 shows the same file folded.
Figure2-9 The file with the folding markers in place.