8

In every version of Visual Studio up to 2013, code wrapped in #regions and inactive code in #if statements are automatically collapsed when you open a C# code file for the first time, when "enter outlining mode when files open" is enabled.

I'm trying to figure out how to enable this in Visual Studio 2015 RC, but even turning on "enter outlining mode when files open" doesn't seem to have any effect. If anything, it seems that the file opens, and then VS activates outlining mode a split second later, without checking to see if anything needs to be collapsed.

2
  • 1
    I have the same issue.
    – winsql
    Aug 27, 2015 at 13:42
  • 1
    This still occurs for me in the latest version of Visual Studio 2015, and when looking at the documentation for the "Enter outlining mode when files open" it tells that "The first time a file is opened, #regions blocks and inactive code blocks collapse" at msdn
    – einord
    Nov 25, 2015 at 19:03

3 Answers 3

2

Well, it looks like the auto-collapse feature works again in VS2015 Update 1, so the answer now seems to be "install Update 1."

3
  • I have Update 1 and this doesn't work when using Ctrl+M, Ctrl+O keybind (or the right-click menu option: "Collapse to Definitions"
    – Keith
    Apr 19, 2016 at 17:37
  • CTRL+M and CTRL + O works to collapse regions in VS 2015 Update 3. Aug 29, 2016 at 18:02
  • It absolutely does not. In fact, Microsoft devs specifically said that the fact that it doesn't has been fixed, but they aren't fixing it for 2015, just 2017. To clear up any confusion: In 2015, in VB, #Regions will not collapse with "Collapse to Definitions" functionality.
    – Keith
    Nov 27, 2017 at 15:47
1

Visual Studio 2015 does not currently have this functionality built in.

You might want to check out the I Hate #Regions extension. It can automatically expand regions when opening a file.

3
  • Visual Studio 2015 does not seem to have this functionality built on, but this extension can automate expanding regions when files are opened. Dec 8, 2015 at 12:05
  • always try to give feedback updating answer, not commenting. Dec 8, 2015 at 12:07
  • 2
    "Expand regions which are automatically collapsed" is the exact opposite of what I want. Currently, nothing in Visual Studio 2015 is automatically collapsed. Dec 12, 2015 at 19:55
0

It looks like it's still a problem with VB, not C#:

"Incorrect VB code collapsing in VS2015 update 1 #9189"

https://github.com/dotnet/roslyn/issues/9189

It's still broken in Update 3, so hopefully they address it in Update 4.

1
  • "This issue was fixed for VS2017. We do not have any plans to backport these fixes to VS2015." - MS Dev
    – Keith
    Nov 27, 2017 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.