Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collapse all inactive preprocessor blocks in Visual Studio

I am working with some third-party code that has a lot of conditional macros. Visual Studio is quite good at detecting the inactive code, i.e. code wrapped in #if...#endif that won't be compiled and I can manually collapse these individually.

I would like to hide the inactive blocks automatically - all of them. Is this possible?

EDIT: is this possible with VS2012? May be a reason to upgrade.

like image 219
paperjam Avatar asked Feb 01 '12 10:02

paperjam


People also ask

How do you collapse all blocks in Visual Studio?

(Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic. (Ctrl+M, Ctrl+O) - Collapses the members of all types. (C++) Collapses a region in the function containing the insertion point.

How do you collapse all codes in VS?

How to Collapse All Source Code in VS Code? To fold all top-level and child elements of your code: Enter the command >fold and hit Enter.

How do I close all methods in visual studio?

How do I minimize all functions in Visual Studio? CTRL + M + O will collapse all.

How do I enable expand collapse code in Visual Studio?

Fold (Ctrl+Shift+[) folds the innermost uncollapsed region at the cursor. Unfold (Ctrl+Shift+]) unfolds the collapsed region at the cursor. Toggle Fold (Ctrl+K Ctrl+L) folds or unfolds the region at the cursor.


1 Answers

I am not aware of a way to automatically collapse, but there is definitely a setting to hide inactive blocks.

The setting is under Tools->Options->Text Editor->C/C++->View

From there, just change "Show Inactive Blocks" to False.

Screen capture of C++ settings for Visual studio Editor

like image 163
John Avatar answered Sep 28 '22 18:09

John