7

I'd like the regions that show up in my Visual Studio window to be expanded by default when I open a code file. Is this possible in VS2010, or is there an extension that will do that for me?

Barring that, is my request a thing that can be written in an extension?

Kevin Chen
  • 994
  • 8
  • 24
thepaulpage
  • 4,614
  • 2
  • 25
  • 39
  • The only builtin thing is turning off regions completely. There is limited macro support for defining your own outlining. –  Sep 17 '10 at 18:18

5 Answers5

8

If you would like Regions turned off, right click any code window, choose Outlining, then Stop Outlining.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • this kind of works, but I was hoping for a more permanent, global solution. – thepaulpage Sep 17 '10 at 20:08
  • See this Visual Studio extension, which automatically expands all regions: http://stackoverflow.com/questions/115694/how-to-permanently-disable-region-folding-in-visual-studio-2008 – Dirk Vollmar Dec 21 '11 at 10:59
2

you could write a macro that calls the Visual Studio Command Edit.StopOutlining for you every time you are opening a document.

This MSDN Page describes how to write a basic macro that handles events: http://msdn.microsoft.com/en-us/library/ee1f34as.aspx Instead of handle the WindowClosing you should handle WindowActivated.

Like this:

Public Sub windowopen(ByVal window As EnvDTE.Window, ByVal lostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
    DTE.ExecuteCommand("Edit.StopOutlining")
End Sub

Of course, this will call Edit.StopOutlining on every window you are opening; so maybe you have to do a little bit of filtering what documenttype was activated.

Noffls
  • 5,397
  • 2
  • 29
  • 36
2

There is a free Visual Studio 2010 extension which will automatically expand all regions for you:

Auto-Expand Visual Studio Regions

Please also see this related question:

How to permanently disable region-folding in Visual Studio

Community
  • 1
  • 1
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
1

For newer Visual Studio Versions (such as 2015 but it should also work for 2010) there is an extension called I hate #Regions. You can download and install it via Tools > Extensions and Updates > Online. It auto expands all regions and lowers the font size of region tags. Hope it helps.

Christoph Meißner
  • 1,511
  • 2
  • 21
  • 40
1

To create a macro that expands all regions for C# files only do the following.

  1. Open the Visual Studio Studio Macros window from Tools > Macros > Macros IDE...

  2. In the EnvironmentEvents vb file in Project Explorer (if there isn't one then create a new module and it will appear) add the following code after the automatically generated code region

    Private Sub WindowEvents_WindowActivated(ByVal GotFocus As EnvDTE.Window, ByVal LostFocus As EnvDTE.Window) Handles WindowEvents.WindowActivated
    If GotFocus.Document.FullName.EndsWith(".cs") Then
        DTE.ExecuteCommand("Edit.StopOutlining")
    End If
    

    End Sub

  3. Save and Build the project

If you need some more help with macros then read this msdn page for more information.

There is one issue with this macro that I'm currently working on is that if you click any file in the solution explorer VS will automatically open it.

Keith K
  • 2,893
  • 4
  • 33
  • 43