13

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.

paperjam
  • 8,321
  • 12
  • 53
  • 79
  • http://stackoverflow.com/questions/982677/visual-studio-command-to-collapse-all-sections-of-code?rq=1 – SridharKritha Feb 10 '14 at 17:40
  • 1
    @SridharKritha Not the same question. There is an element of seductiveness to this question, the one linked is a solution to collapse all, regardless of whether or not the block is active – Assimilater May 13 '16 at 14:48
  • I feel like this is a well-formed question. Sad to see the responses from 2012 seem to be off the understanding. I would guess it's not possible without making a new VS extension. – Assimilater May 13 '16 at 14:54

1 Answers1

2

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

John
  • 1,379
  • 8
  • 16
  • 4
    If you set this to true, you can have inactive blocks be colored differently, like opacity 10. Setting this to False will make no difference whatsoever. ;) – gulgi Jan 28 '17 at 10:48
  • gulgi is right. The setting "Show Inactive Blocks" is really controlling the question "Should blocks of Inactive Code be shown differently from active code so that you can *see* that they are *Inactive* Blocks?" If it is changed to False, then the opacity options for Inactive Code are grayed out and the Inactive Code will be shown in the same way as active code. – Eric Sep 10 '22 at 01:16