如何在 Visual Studio VB.NET 中禁用区域折叠或展开所有区域?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1105442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable region collapsing or expand ALL regions in Visual Studio VB.NET?
提问by Tony_Henrich
In Visual Studio C# (2008), Ctrl+M+Lexpand all the regions.
在Visual Studio C#(2008),Ctrl+ M+L展开所有地区。
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.
在文件打开期间不折叠。我在 VB.NET 中没有看到任何等价物。
Is there a way to expand all the regions, not just the one which has focus in VB.NET?
有没有办法扩展所有区域,而不仅仅是在 VB.NET 中关注的区域?
Or a macro or add-in that does it? I just hate not being able to see all the code.
或者一个宏或插件可以做到这一点?我只是讨厌看不到所有代码。
回答by Sebastian
In Visual Studio 2012 and 2013 there is an option for deactivating collapsing (called 'outlining mode').
在 Visual Studio 2012 和 2013 中,有一个选项可以停用折叠(称为“大纲模式”)。
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.
但是您将完全失去折叠/展开的功能。
回答by Sebastian
If you are willing to remove regions you can try this:
如果您愿意删除区域,可以尝试以下操作:
Ctrl+F
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 stringend
region
- Match the stringregion
.*
- Match zero or more of any other characters$
- Match the end of the line
^
- 匹配一行的开头\s*
- 匹配零个或多个空白字符#
- 匹配一个#
字符(end)?
- 可选匹配字符串end
region
- 匹配字符串region
.*
- 匹配零个或多个任何其他字符$
- 匹配行尾
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.
这将有效地找到所有#region
或#endregion
行,无论它们是否缩进,以及它们后面是否有描述文本。
回答by jvanderh
In the Edit Menu, the Outlining submenu, you have all the options. Including Toggle All Outlining(Ctrl+M+Lby default).
在编辑菜单、大纲子菜单中,您拥有所有选项。包括切换所有大纲(默认情况下为Ctrl+ M+ L)。
Maybe your key mappings were altered.
也许你的键映射被改变了。
If you so desire, you can even select menu:
如果您愿意,您甚至可以选择菜单:
Edit -> Outlining -> Stop Outlining
回答by John Cruz
In VB.Net, do a Search and Replace and select Use Hidden and Use Regex:
在 VB.Net 中,执行搜索和替换并选择使用隐藏和使用正则表达式:
Replace:
代替:
^.*\#(end)*(:Wh)*region.*\n
With:
和:
回答by NotDan
I wrote an extension to do this (and more), and it works for VB and C#. See this answer for more info:
我写了一个扩展来做到这一点(以及更多),它适用于 VB 和 C#。有关更多信息,请参阅此答案:
回答by Scott Kaiser
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.
减号出现,我能够折叠/展开区域。
回答by JaredPar
That's pretty odd. The default profile settings for VB.Net and C# should bind the outlining functions to Ctrl+M, Ctrl+Lcombos.
这很奇怪。VB.Net 和 C# 的默认配置文件设置应将大纲功能绑定到Ctrl+ M、Ctrl+L组合。
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.
您的个人资料可能处于一种奇怪的状态。尝试将您的配置文件重置为 VB.Net 设置,看看是否能解决问题。
Tools
→ Import / Export Settings
→ Reset All Settings
→ VB.Net Profile
Tools
→ Import / Export Settings
→ Reset All Settings
→VB.Net Profile
回答by Fil
I came up with this trick:
我想出了这个技巧:
Ctrl+F
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 Returnand keep it pressed until VS notify the search is endend. As a result all your '#region's have been expanded in very few seconds.
然后按住Return它直到 VS 通知搜索结束。因此,您的所有“#region”都在几秒钟内扩展完毕。