Collapse All Regions

July 9, 2021Visual Studio

Recently I switched to Visual Studio 2022, the preview version. It works flawlessly for my projects, but there's still one thing I'm missing... The ability to make all #region blocks collapse in a C# source code file.

Instead of waiting for an extension to support this, or even better, for Microsoft to put this command into Visual Studio by default, I dipped my toes into IDE Extension development and whipped up one that adds the desired Collapse All Regions command into the Edit menu. This command can also be accessed by the default keyboard shortcut Ctrl-M, Ctrl-R

It can be downloaded from the Visual Studio Extension Marketplace or by using Visual Studio 2022's Extension Manager.