1. Computing

When You Fold, What Do You Frequently Fold (Collapsible Code Blocks in Delphi)?

By November 29, 2010

Follow me on:

in Polls ::

Introduced in Delphi 2006, code folding lets you collapse or expand regions or blocks of code. Collapsing your code creates a hierarchical view of the code and makes it easier to read and navigate. The collapsed code is not deleted, but hidden from view in Code Editor until you expand it.

Delphi generates code that contains code folding regions, but you can add your own collapsible regions as needed.

Are you using code folding? I do, every day. If you do also, what do you fold:


November 29, 2010 at 4:33 pm
(1) LDS says:

I never use folding. It is useful in C# because all of the automatically generate code there. Delphi, luckily, hasn’t. I prefer by far something like GExpert’s procedure list to jump easily within methods. The only thing I would like to fold is something Delphi does not support automatically: $IFDEFs. Sometimes I would like to hide debugging code without having to declare regions by hand.

November 30, 2010 at 4:44 pm
(2) G says:

Where’s the “Never use it, hate it” option?

Reasons why I don’t like it:
- It uses up screen space
- It makes selecting a line (via mouse in margin) harder
- It struggles with large pas files
- It hides code, I know thats what its for but if your code is too complex to view nicely, or just plain messy, you might want to consider splitting it up (or other)

What I do:
- I tend to jump around code between units and up and down through large pas files a lot
- I use bookmarks, ctrl+shift+uparrow, ctrl+click & fwd/back navigation, and the structure view
- For local navigation I use the mouse wheel, ctrl+up/downarrow, PgUp/PgDown
- I have two monitors so if I need to reference other code I can create a New Edit Window

You know, another thing which is a bit annoying is wide screen monitors. Can’t fit as many lines of code on the screen.

November 30, 2010 at 6:14 pm
(3) Joey says:

if there is an “unfold all” why is there not a “fold all”?

December 1, 2010 at 4:03 am
(4) Flemming says:

I love the Code Folding but rarely use it as Delphi doesn’t remember which sections are folded.

Could I only make Delphi remember which sections that was folded, when I reload my source project, it would be my most frequent used function (after save and compile).

Maybe there is a function to make Delphi remember it, but I haven’t been able to find where. Only to turn on or off Code Folding.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.