code folding

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 13 11:26:22 PDT 2017


On Monday, March 13, 2017 17:29:41 Inquie via Digitalmars-d-learn wrote:
> Does D have any nice way to specify a block for cold folding? I
> have a very large set of structs and I'd like to be able to code
> fold them all at once and together.
>
> I have been using
>
> static if(true)
> {
>      ... junk
> }
>
> but the static if is uninformative since that is the only line
> that is shown when folded. A comment helps but still kinda ugly.
>
> C# has #regions and hopefully D has something as useful.

Code-folding is an IDE thing, not a language thing. So, it's not the sort of
thing that would normally be built into a language. If Microsoft did it with
C#, it's only because they assumed that everyone would use Visual Studio,
but I would guess that #region actually does more than just enable code
folding. However, since I've done relatively little with C#, I don't know.

So, how code folding works is going to depend entirely on whatever IDE or
code editor you're using. If you told us which IDE you were using, maybe
someone here could give you some tips, but it's going to be specific to your
IDE. Normally, I think that folks just code fold based on braces if they're
doing fode folding, but I don't know. I've certainly never heard of anyone
adding anything to a source file just to enable code folding.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list