Collapse ALL #region in Visual Studio 2012

15,757

Solution 1

ctrl+m, ctrl+s will collapse the current region. You can select multiple regions manually and collapse them that way.

Since the command "Collapse all open region" doesn't exist, you could always try to create a new one; In that case, check out this post: How to add commands to Visual Studio 2012?

Solution 2

You can't collapse just regions, but the shortcut key chord: ctrl+m, ctrl+l will do it for everything.

Solution 3

You can do this by installing the Menees VS Tools extension. It's available through the Visual Studio Gallery as well (in VS2013: Tools > Extensions and Updates... > Online > [Type Menees into the search box])

Solution 4

Highlight everything CTR+A Then CTR+m CTR-m (2 times!!)

Solution 5

In an answer to a similar question Ray Pietrzak posted code for a macro that will do this. I used the Visual Commander extension to create a new "command", and I pasted Ray's code for the ExpandAllRegions and CollapseAllRegions methods into the command. I modified both methods so that they take a "DTE" parameter like so:

  Sub ExpandAllRegions(DTE As DTE2)

and

  Sub CollapseAllRegions(DTE As DTE2)

and I edited the Run method of the command like so:

  Sub Run(DTE As DTE2, package As Microsoft.VisualStudio.Shell.Package) Implements VisualCommanderExt.ICommand.Run
      CollapseAllRegions(DTE)
  End Sub

The command can then be added to menu, toolbar, or keyboard shortcut.

Share:
15,757

Related videos on Youtube

poudigne
Author by

poudigne

I am full-time C# programmer with 10 years of experience. I do game developpement as hobby.

Updated on September 14, 2022

Comments

  • poudigne
    poudigne over 1 year

    First of all, no CTRL+M, CTRL+O is not the answer. For me, this is collapsing #Region, ///Comments, and Methods and I hate that.

    I'd like to collapse/expand ONLY #region sections. I am using Visual Studio 2012 and Resharper.

  • Justin German
    Justin German over 7 years
    This will collapse more than regions