visual-studio 命令折叠所有代码段?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/982677/
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
Command to collapse all sections of code?
提问by Mr. Flibble
In Visual Studio is there a command to collapse/expand all the sections of code in a file?
在 Visual Studio 中是否有折叠/展开文件中所有代码部分的命令?
回答by Bob
CTRL+ M+ Owill collapse all.
CTRL+ M+O将崩溃所有。
CTRL+ M+ Lwill expand all. (in VS 2013 - Toggle All outlining)
CTRL+ M+L将全部展开。(在 VS 2013 中 - 切换所有大纲)
CTRL+ M+ Pwill expand all and disable outlining.
CTRL+ M+P将全部展开,并禁用大纲。
CTRL+ M+ Mwill collapse/expand the current section.
CTRL+ M+M将折叠/展开当前部分。
CTRL+ M+ Awill collapse all even in Html files.
CTRL+ M+A将崩溃甚至都在HTML文件中。
These options are also in the context menu under Outlining.
这些选项也在大纲下的上下文菜单中。
Right click in editor -> Outlining to find all options. (After disabling outlining, use same steps to enable outlining.)
在编辑器中右键单击 -> 大纲以查找所有选项。(禁用大纲后,使用相同的步骤启用大纲。)


回答by Bhavesh Kachhadiya
The following key combinations are used to do things:
以下组合键用于执行操作:
CTRL+ M+ M→ Collapse / Expand current preset area (e.g. Method)
CTRL+ M+ M→ 折叠/展开当前预设区域(例如Method)
CTRL+ M+ H→ Collapse / Hide (Expand) current selection
CTRL+ M+ H→ Collapse / Hide (Expand) 当前选择
CTRL+ M+ O→ Collapse all(Collapse declaration bodies)
CTRL+ M+ O→o全部折叠(折叠声明体)
CTRL+ M+ A→ Collapse all
CTRL+ M+ A→ 折叠all
CTRL+ M+ X→ Expand all
CTRL+ M+ X→ E xpand all
CTRL+ M+ L→ Toggle all
CTRL+ M+ L→l全部切换
There some options in the context menu under Outlining.
大纲下的上下文菜单中有一些选项。
回答by Scott Ivey
CTL+ M+ Lexpands all
CTL+ M+L展开所有
CTL+ M+ Ocollapses all
CTL+ M+O全部折叠
In the MSDN article "Default Keyboard Shortcuts in Visual Studio,"see the section "Text Editor"if you're looking for other shortcuts - these 2 are just a few of the many that are available.
在 MSDN 文章“Visual Studio 中的默认键盘快捷方式”中,如果您正在寻找其他快捷方式,请参阅“文本编辑器”部分- 这两个只是可用的众多快捷方式中的一小部分。
回答by M4N
Ctrl+Mexpands region.
Ctrl+M扩大区域。
Ctrl+Lcollapses region.
Ctrl+L折叠区域。
回答by AvatarOfChronos
- Fold/Unfold the current code block – Ctrl+M, Ctrl+M
- Unfold all – Ctrl+M, Ctrl+L
- Stop outlining – Ctrl+M, Ctrl+P
- Fold all – Ctrl+M, Ctrl+O
- 折叠/展开当前代码块 – Ctrl+ M, Ctrl+M
- 展开全部 – Ctrl+ M, Ctrl+L
- 停止勾画 – Ctrl+ M, Ctrl+P
- 全部折叠 – Ctrl+ M, Ctrl+O
回答by Gelásio
In Visual Studio 2017, It seems that this behavior is turned off by default. It can be enabled under Tools > Options > Text Editors > C# > Advanced > Outlining > "Collapse #regions when collapsing to definitions"
在 Visual Studio 2017 中,此行为似乎默认关闭。它可以在工具>选项>文本编辑器>C#>高级>大纲>“折叠到定义时折叠#regions”下启用
回答by Ray
CTL+ M+ Acollapses all
CTL+ M+A全部折叠
works for me, whereas
对我有用,而
CTL+ M+ O
CTL+ M+O
does not
才不是
回答by CodeLikeBeaker
Are you refering to the toggle outlining?
你是指切换大纲吗?
You can do: Control+ Mthen Control+ Lto toggle all outlining
您可以执行以下操作: Control+M然后Control+L切换所有大纲
回答by Nathan Chase
In Visual Studio 2013:
在 Visual Studio 2013 中:
CTL+ M+ Acollapses all
CTL+ M+A全部折叠
CTL+ M+ Lexpands all
CTL+ M+L展开所有
回答by Harishh
Below are all what you want:
你想要的都在下面:
- Collapse / Expand current Method
- 折叠/展开当前方法
CTRL+ M+ M
CTRL+ M+M
- Collapse / Expand current selection
- 折叠/展开当前选择
CTRL+ M+ H
CTRL+ M+H
- Collapse all
- 全部收缩
CTRL+ M+ O
CTRL+ M+O
CTRL+ M+ A
CTRL+ M+A
- Expand all
- 展开全部
CTRL+ M+ X
CTRL+ M+X
CTRL+ M+ L
CTRL+ M+L

