Automatically open regions in Visual Studio 2010

I would like the areas that appear in my Visual Studio window to expand by default when I open the code file. Is this possible in VS2010, or is there an extension that will do this for me?

Is it forbidden that my request is a thing that can be written to the extension?

+6
c # visual-studio
source share
5 answers

you can write a macro that calls the Visual Studio Edit.StopOutlining for you every time you open a document.

This MSDN page describes how to write a basic macro that processes events: http://msdn.microsoft.com/en-us/library/ee1f34as.aspx Instead of the WindowClosing handle WindowClosing you must 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 in every window that you open; therefore, you may need to process a little what type of document was activated.

+2
source share

If you want the Regions to disconnect, right-click any code window, select Outlining , then Stop Outlining .

+7
source share

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

Auto Expand Visual Studio Areas

Also see this question:

How to permanently disable area addition in Visual Studio

+2
source share

To create a macro that expands all regions for C # files, follow these steps:

  • Open the Visual Studio Studio Macro Window under Tools> Macros> IDE Macros ...

  • In the EnvironmentEvents file in Project Explorer (if not, create a new module and it will appear) add the following code after the automatically generated code area

     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

  • Save and build a project

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

There is one problem with this macro that I'm working on right now is that if you click on any file in VS Solution Explorer, it will open it automatically.

+1
source share

For newer versions of Visual Studio (e.g. 2015, but this should also work in 2010) there is an extension called I Hate #Regions . You can download and install it through Tools> Extensions and Updates> Internet. It automatically expands all regions and reduces the font size of region tags. Hope this helps.

+1
source share

All Articles