What\'s the C++ equivalent of #region for C++ so I can put in custom code collapsible bits and make my code a little easier to read?
The first answer from this question mentions another alternative. It is not applicable in all situations, though.
Method: Use {...} instead which natively supports code collapsing in Visual Studio.
Enable option: Tools -> Options -> Text Editor -> C/C++ -> Formatting -> OutLine Statement Blocks -> True.
Put your in different scopes {...}, then it will collapse the code in different scopes:
Just an addition to other answers. The region definition varies from IDE to IDE.
For Mac development in Xcode you can use a pragma:
#pragma mark
In addition to #pragma region
…#pragma endregion
for Visual Studio, many IDEs support the following syntax for regions in any {}
-delimited, //
-commented language:
//{ Region header text.
…
//}
Notable examples include Code::Blocks and FlashDevelop, and any other editor that uses the Scintilla editing component, such as Notepad++, Geany, Komodo Edit, and many more.
There isn't an equivalent in C++. However IDEs should be able to collapse sections.
It is also possible to use something like this:
#pragma region
#pragma endregion A comment about the region.
But probably not very portable