简体   繁体   English

Visual Studio 2015 - 自动折叠#regions 和非活动代码

[英]Visual Studio 2015 - auto-collapse #regions and inactive code

In every version of Visual Studio up to 2013, code wrapped in #region s 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.在截至 2013 年的每个 Visual Studio 版本中,当您第一次打开 C# 代码文件时,如果启用了“打开文件时进入大纲模式”,包装在#region中的代码和#if语句中的非活动代码会自动折叠。

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.我试图弄清楚如何在 Visual Studio 2015 RC 中启用此功能,但即使打开“打开文件时进入大纲模式”似乎也没有任何效果。 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.如果有的话,似乎文件打开了,然后VS 在一瞬间激活大纲模式,而不检查是否需要折叠任何内容。

好吧,看起来自动折叠功能在 VS2015 Update 1 中再次起作用,所以现在的答案似乎是“安装 Update 1”。

Visual Studio 2015 does not currently have this functionality built in. Visual Studio 2015 当前没有内置此功能。

You might want to check out the I Hate #Regions extension.您可能想查看I Hate #Regions扩展。 It can automatically expand regions when opening a file.它可以在打开文件时自动扩展区域。

It looks like it's still a problem with VB, not C#:看起来它仍然是VB的问题,而不是C#:

" Incorrect VB code collapsing in VS2015 update 1 #9189 " VS2015 更新 1 #9189 中不正确的 VB 代码崩溃

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

It's still broken in Update 3, so hopefully they address it in Update 4.它在更新 3 中仍然被破坏,所以希望他们在更新 4 中解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM