Collapsing Regions in Visual Studio

I like using regions in Visual Studio. They make it much easier to move around code. I’m writing C++ at the moment and functions and code blocks are automatically tuned into regions, which is nice.

If you want to collapse and open them quickly there are a couple of control sequences that you might find useful.

CTRL+M CTRL+O

This collapses all the regions. You can hold down the control key and press M followed by O.

CTRL+M CTRL+L

This collapses all the regions recursively. So if you have regions inside regions you might end up with just one line in the editor if you use this..

These sequences are toggles, so pressing them again will open all the regions. I find them especially useful when copying or moving code, in that you can select the collapsed region and it will select all the code in the region.