Preserve Code Folding When Reopening a Project

Post date: Mar 14, 2010 1:06:03 AM

Introduced in Delphi 8, code folding is a feature of the Delphi IDE which lets you collapse (hide) and expand (show) your code to make it easier to navigate and read. By default, Delphi Code editor adds folding regions to classes, function and procedures and unit section. By default, all regions are expanded. Note the little "-" sign to the left of a procedure declaration line. Click it to collapse the procedure implementation code, click it again to expand it.

Custom collapsible code blocks in Delphi Code Editor can be easily created using the "{$REGION 'Caption'}" and "{$ENDREGION}" directives. If you collapse a region and close the project, next time you open the project (a code unit) the "collapsed" code block will be expanded. Code folding enables the user to read and navigate their code more easily but, when the project is closed, all the regions are expanded.

In Delphi 2005, a feature was introduced to preserve the code folding preferences so that the folded code can be folded after reopening the project.

Tools - Options - Environment Options - Autosave options - Project desktop (check box) .

Delphi saves the arrangement of your desktop when you close a project or close the IDE. When you later open the same project, all files opened when the project was last closed are opened again, regardless of whether they are used by the project. Folded code will stay folded when the project is reopened. :)

Read another article here:

http://delphi.about.com/od/delphitips2009/qt/preserve-code-folding.htm

Screenshot coming later.