Tony_Henrich
Tony_Henrich

Reputation: 44205

How to disable region collapsing or expand ALL regions in Visual Studio VB.NET?

In Visual Studio C# (2008), Ctrl+M+L expand all the regions.

There's also a setting in menu:

Tools -> Options -> Text Editor -> C# -> Advanced

to not collapse during file open. I see no equivalents in VB.NET.

Is there a way to expand all the regions, not just the one which has focus in VB.NET?

Or a macro or add-in that does it? I just hate not being able to see all the code.

Upvotes: 58

Views: 39104

Answers (9)

herve
herve

Reputation: 610

To disable region folding in Visual Studio 2022 and for C#, you can find it in "Settings", "Text Editor" / "C#" / "Advanced" then in the "Outlining" section :

Disable regions folding in Visual Studio 2022

Upvotes: 1

user295190
user295190

Reputation:

If you are willing to remove regions you can try this:

Ctrl+F

  • Quick Replace
  • Find Options
  • Use: Regular Expressions

Find What:

^\s*#(end)?region.*$

Replace with:

[leave replace box empty]

Explanation:

  • ^ - Match the start of a line
  • \s* - Match zero or more whitespace characters
  • # - Match one # character
  • (end)? - Optionally match the string end
  • region - Match the string region
  • .* - Match zero or more of any other characters
  • $ - Match the end of the line

This will effectively find all #region or #endregion lines, whether they are indented or not, and whether they have description text after them or not.

Upvotes: 10

Sebastian
Sebastian

Reputation: 2944

In Visual Studio 2012 and 2013 there is an option for deactivating collapsing (called 'outlining mode').

You can find it under:

Text-Editor->Basic->VB Specific

and then uncheck "Enable outlining mode".

But you will then lose the feature for collapse/expand at all.

Upvotes: 28

JaredPar
JaredPar

Reputation: 755387

That's pretty odd. The default profile settings for VB.Net and C# should bind the outlining functions to Ctrl+M, Ctrl+L combos.

It's possible that your profile is in a weird state. Try resetting your profile to VB.Net settings and see if that fixes the problem.

ToolsImport / Export SettingsReset All SettingsVB.Net Profile

Upvotes: 1

jvanderh
jvanderh

Reputation: 2955

In the Edit Menu, the Outlining submenu, you have all the options. Including Toggle All Outlining (Ctrl+M+L by default).

Maybe your key mappings were altered.

If you so desire, you can even select menu:

Edit -> Outlining -> Stop Outlining

Upvotes: 8

Fil
Fil

Reputation: 1060

I came up with this trick:

Ctrl+F

  • Quick Replace
  • Find:

#Region

  • Search in: current document (or entire project or wherever you need to expand regions)
  • Search in hidden text

Then press Return and keep it pressed until VS notify the search is endend. As a result all your '#region's have been expanded in very few seconds.

Upvotes: -3

Scott Kaiser
Scott Kaiser

Reputation: 11

Once I changed:

#Region Form Level Events
#End Region

To (note the addition of quotes):

#Region "Form Level Events"
#End Region

The minus signed appeared and I was able to collapse/expand Regions.

Upvotes: 1

NotDan
NotDan

Reputation: 32233

I wrote an extension to do this (and more), and it works for VB and C#. See this answer for more info:

Hiding the regions in Visual Studio

Upvotes: 2

John Cruz
John Cruz

Reputation: 1592

In VB.Net, do a Search and Replace and select Use Hidden and Use Regex:

Replace:

^.*\#(end)*(:Wh)*region.*\n

With:

Upvotes: 3

Related Questions