views:

408

answers:

4

I was wondering if there is an equivalent to Visual Studio's #regions in RAD Studio.

We use CodeGear's delphi and c++builder IDEs where I work and I would love to be able to use something like regions.

My coworkers and I have yet to find an equivalent way of grouping code... do you know of any?

Thanks!

+15  A: 
eKek0
This is exactly what I was looking for. Thank you very much.
stevosaurus
FYI, I believe this was introduced in Delphi 2005.
Jim McKeeth
+4  A: 

For C++Builder, use

#pragma region [name]
and
#pragma end_region
, as described in the documentation.

Moritz Beutel
There is however a thing, at least when using C++ Builder, the IDE does not remember which regions you have folded, and have a nasty tendency of unfolding them whenever you edit other parts of the document. So each time you open the file you have to fold the regions again, if that is what you wish.
TommyA
Yes, that's quite annoying, and I think it's a bug. For folded classes/functions, this was fixed in C++Builder 2010, but not yet for #pragma region...
Moritz Beutel
C++Builder 2010 Update 4/5 fixes this for #pragma region as well.
Moritz Beutel
+2  A: 

As an addition to eKek0's answer note that (at least in d2009) you can select the code lines that you want to put in a region, right click and choose Surround | Region. You'll be prompted for the region name.

MarkF
A: 

What is the use of region if its not working correct? Sure u can fold it and its looks cool, but after u edit some code or make new function its automaticly unfolds. This bug is on Borlad studio c++, rad studio 2009/2010. Useless.

Yeah, we discovered this shortly after starting to use the regions. It works great when editing delphi code in the (same release version even), but all of the versions of c++ builder act in the way you describe.
stevosaurus
That's fixed in 2010 :)
Moritz Beutel