In Visual Studio (2008) is there a command to collapse/expand all the sections of code in a file?
在Visual Studio(2008)中,有一个命令可以崩溃/扩展文件中的所有代码段吗?
18 个解决方案
#1
2492
CTRL + M + O will collapse all.
CTRL + M + O会崩溃。
CTRL + M + L will expand all. (in VS 2013 - Toggle All outlining)
CTRL + M + L将会展开。(在VS 2013 -切换所有概述)
CTRL + M + P will expand all and disable outlining.
CTRL + M + P将会展开所有内容,并禁用大纲。
CTRL + M + M will collapse/expand the current section.
CTRL + M + M将崩溃/展开当前部分。
CTRL + M + A will collapse all even in Html files.
即使在Html文件中,CTRL + M + A也会崩溃。
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 outlinging.)
右键单击编辑器->概要,查找所有选项。(在禁用提纲后,使用相同的步骤进行输出。)
#2
124
The following key combinations are used to do things:
下面的关键组合是用来做事情的:
CTRL + M + M ------> Collapse / Expand current preset area (e.g. Method)
CTRL + M + M ----->崩溃/扩展当前预设区域(如方法)
CTRL + M + H ------> Collapse / Hide (Expand) current selection
CTRL + M + H ----->崩溃/隐藏(扩展)当前选择。
CTRL + M + O ------> Collapse all(Collapse declaration bodies)
CTRL + M + O ----->崩溃(崩溃声明体)
CTRL + M + A ------> Collapse all
CTRL + M + A --->崩溃。
CTRL + M + X ------> Expand all
CTRL + M + X --->展开。
CTRL + M + L ------> Toggle all
CTRL + M + L ----->切换所有。
There some options in the context menu under Outlining.
在上下文菜单中列出了一些选项。
#3
102
CTL + M + L expands all
CTL + M + L扩展所有。
CTL + M + O collapses 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的默认键盘快捷方式”中,如果您正在寻找其他快捷方式,请参阅“文本编辑器”一节——这两个只是其中一些可用的。
#4
37
Ctrl+M expands region.
Ctrl + M扩展区域。
Ctrl+L collapses region.
Ctrl + L崩溃。
#5
29
- Fold/Unfold the current code block – Ctrl+M, Ctrl+M
- 折叠/展开当前代码块- Ctrl+M, Ctrl+M。
- Unfold all – Ctrl+M, Ctrl+L
- 展开所有- Ctrl+M, Ctrl+L。
- Stop outlining – Ctrl+M, Ctrl+P
- 停止概述- Ctrl+M, Ctrl+P。
- Fold all – Ctrl+M, Ctrl+O
- 折叠所有- Ctrl+M, Ctrl+O。
#6
20
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# >高级>概述>“崩溃的区域,崩溃到定义”
#7
13
CTL + M + A collapses all
CTL + M + A崩溃。
works for me, whereas
为我工作,而
CTL + M + O
即CTL + M + O。
does not
不
#8
13
Are you refering to the toggle outlining?
你指的是toggle大纲吗?
You can do: Control + M then Control + L to toggle all outlining
你可以这样做:控制+ M然后控制+ L切换所有大纲。
#9
12
In Visual Studio 2013:
在Visual Studio 2013中:
CTL + M + A collapses all
CTL + M + A崩溃。
CTL + M + L expands all
CTL + M + L扩展所有。
#10
10
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。
#11
9
If you mean shortcut then
如果你说的是捷径的话。
CTRL + M + M: This one will collapse the region your cursor is at whether its a method, namespace or whatever for collapsing code blocks, regions and methods. The first will collapse only the block/method or region your cursor is at while the second will collapse the entire region you are at.
CTRL + M + M:这一个将会破坏你的光标所在的区域,不管它是一个方法、名称空间还是其他的代码块、区域和方法。第一个将只会崩溃你的光标所在的块/方法或区域,而第二个将会破坏你所处的整个区域。
http://www.dev102.com/2008/05/06/11-more-visual-studio-shortcuts-you-should-know/
http://www.dev102.com/2008/05/06/11-more-visual-studio-shortcuts-you-should-know/
#12
9
Press
新闻
CTL + A
CTL +一个
Then
然后
CTL + M + M
CTL + M + M。
To compress all, including child nodes, in XML-files.
在xml文件中压缩所有内容,包括子节点。
#13
4
To collapse all use:
崩溃所有使用:
Ctrl + M and Ctrl+A
Ctrl+ M, Ctrl+A。
All shortcuts for VS 2012/2013/2015 available at http://visualstudioshortcuts.com/2013/
所有关于VS 2012/2013/2015的快捷方式都可以在http://visualstudioshortcuts.com/2013/上找到。
#14
2
In case of ugrading to Visual Studio 2010, 2012, 2013 or 2015, there's a Visual Studio extension to show current registered keyboard shortcuts, IntelliCommand.
在Visual Studio 2010、2012、2013或2015年,有一个Visual Studio扩展来显示当前注册的键盘快捷键,IntelliCommand。
#15
#16
1
None of these worked for me. What I found was, in the editor, search the Keyboard Shortcuts
file for editor.foldRecursively
. That will give you the latest binding. In my case it was CMD + K, CMD + [.
这些都不适合我。我发现,在编辑器中,搜索编辑器的快捷键文件。这将给您最新的绑定。在我的例子中是CMD + K, CMD +[。
#17
0
Visual Studio can help you find the answer to your question in a couple of different ways.
Visual Studio可以通过几种不同的方式帮助您找到问题的答案。
Type Ctrl + Q to access Quick Launch, and then enter "collap". Quick Launch will display something like:†
键入Ctrl + Q以访问快速启动,然后输入“collap”。快速启动会显示一些类似的东西。
Menus (1)
Edit -> Outlining -> Collapse to Definitions (Ctrl+M, Ctrl+O)
NuGet Packages (1)
Search Online for NuGet Packages matching 'collap'
From there, enter "outlining" to find other menu entries related to outlining:
从那里,输入“提纲”,找到与提纲相关的其他菜单条目:
Menus (5)
Edit -> Outlining -> Toggle Outlining Expansion (Ctrl+M, Ctrl+M)
Edit -> Outlining -> Toggle All Outlining (Ctrl+M, Ctrl+L)
Edit -> Outlining -> Stop Outlining (Ctrl+M, Ctrl+P)
Edit -> Outlining -> Stop Hiding Current (Ctrl+M, Ctrl+U)
Edit -> Outlining -> Collapse to Definitions (Ctrl+M, Ctrl+O)
Options (4)
Text Editor -> Basic -> VB Specific (Change outline mode, Automatic inser...
...
However, note that Quick Launch will show you only those commands that are available as Visual Studio menu entries. To find other keyboard-related commands related to collapsing sections of code, in the Visual Studio menu bar click:
但是,请注意,快速启动只会显示那些作为Visual Studio菜单项可用的命令。在Visual Studio菜单栏中,要找到与代码崩溃相关的其他与键盘相关的命令,请单击:
Tools -> Options -> Environment -> Keyboard
This will display the keyboard section in the Options dialog box. In the "Show commands containing" text box, enter "edit.collap". Visual Studio will display a list that is something like:
这将显示选项对话框中的键盘部分。在“包含”文本框的“显示命令”中,输入“edit.collap”。Visual Studio会显示一个类似的列表:
Edit.CollapseAllincurrentblock
Edit.CollapseAllOutlining Ctrl+M, Ctrl+A (Text Editor)
Edit.CollapseBlockcurrentblock
Edit.CollapseCurrentRegion Ctrl+M, Ctrl+S (Text Editor)
Edit.CollapseTag Ctrl+M, Ctrl+T (Text Editor)
Edit.CollapsetoDefinitions Ctrl+M, Ctrl+O (Text Editor)
You'll need to click each command to see its associated keyboard shortcut.
您需要单击每个命令来查看其关联的快捷键。
† My examples taken from Visual Studio 2013.
从Visual Studio 2013中获得的例子。
#18
0
If you want to collapse/expand an area within a class/method (instead of collapsing the entire class/method), you may create custom regions as follow:
如果您想在类/方法中折叠/展开一个区域(而不是崩溃整个类/方法),您可以创建自定义区域如下:
#region AnyNameforCollapsableRegion
//Code to collapse
#endregion
参考:https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-region
#1
2492
CTRL + M + O will collapse all.
CTRL + M + O会崩溃。
CTRL + M + L will expand all. (in VS 2013 - Toggle All outlining)
CTRL + M + L将会展开。(在VS 2013 -切换所有概述)
CTRL + M + P will expand all and disable outlining.
CTRL + M + P将会展开所有内容,并禁用大纲。
CTRL + M + M will collapse/expand the current section.
CTRL + M + M将崩溃/展开当前部分。
CTRL + M + A will collapse all even in Html files.
即使在Html文件中,CTRL + M + A也会崩溃。
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 outlinging.)
右键单击编辑器->概要,查找所有选项。(在禁用提纲后,使用相同的步骤进行输出。)
#2
124
The following key combinations are used to do things:
下面的关键组合是用来做事情的:
CTRL + M + M ------> Collapse / Expand current preset area (e.g. Method)
CTRL + M + M ----->崩溃/扩展当前预设区域(如方法)
CTRL + M + H ------> Collapse / Hide (Expand) current selection
CTRL + M + H ----->崩溃/隐藏(扩展)当前选择。
CTRL + M + O ------> Collapse all(Collapse declaration bodies)
CTRL + M + O ----->崩溃(崩溃声明体)
CTRL + M + A ------> Collapse all
CTRL + M + A --->崩溃。
CTRL + M + X ------> Expand all
CTRL + M + X --->展开。
CTRL + M + L ------> Toggle all
CTRL + M + L ----->切换所有。
There some options in the context menu under Outlining.
在上下文菜单中列出了一些选项。
#3
102
CTL + M + L expands all
CTL + M + L扩展所有。
CTL + M + O collapses 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的默认键盘快捷方式”中,如果您正在寻找其他快捷方式,请参阅“文本编辑器”一节——这两个只是其中一些可用的。
#4
37
Ctrl+M expands region.
Ctrl + M扩展区域。
Ctrl+L collapses region.
Ctrl + L崩溃。
#5
29
- Fold/Unfold the current code block – Ctrl+M, Ctrl+M
- 折叠/展开当前代码块- Ctrl+M, Ctrl+M。
- Unfold all – Ctrl+M, Ctrl+L
- 展开所有- Ctrl+M, Ctrl+L。
- Stop outlining – Ctrl+M, Ctrl+P
- 停止概述- Ctrl+M, Ctrl+P。
- Fold all – Ctrl+M, Ctrl+O
- 折叠所有- Ctrl+M, Ctrl+O。
#6
20
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# >高级>概述>“崩溃的区域,崩溃到定义”
#7
13
CTL + M + A collapses all
CTL + M + A崩溃。
works for me, whereas
为我工作,而
CTL + M + O
即CTL + M + O。
does not
不
#8
13
Are you refering to the toggle outlining?
你指的是toggle大纲吗?
You can do: Control + M then Control + L to toggle all outlining
你可以这样做:控制+ M然后控制+ L切换所有大纲。
#9
12
In Visual Studio 2013:
在Visual Studio 2013中:
CTL + M + A collapses all
CTL + M + A崩溃。
CTL + M + L expands all
CTL + M + L扩展所有。
#10
10
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。
#11
9
If you mean shortcut then
如果你说的是捷径的话。
CTRL + M + M: This one will collapse the region your cursor is at whether its a method, namespace or whatever for collapsing code blocks, regions and methods. The first will collapse only the block/method or region your cursor is at while the second will collapse the entire region you are at.
CTRL + M + M:这一个将会破坏你的光标所在的区域,不管它是一个方法、名称空间还是其他的代码块、区域和方法。第一个将只会崩溃你的光标所在的块/方法或区域,而第二个将会破坏你所处的整个区域。
http://www.dev102.com/2008/05/06/11-more-visual-studio-shortcuts-you-should-know/
http://www.dev102.com/2008/05/06/11-more-visual-studio-shortcuts-you-should-know/
#12
9
Press
新闻
CTL + A
CTL +一个
Then
然后
CTL + M + M
CTL + M + M。
To compress all, including child nodes, in XML-files.
在xml文件中压缩所有内容,包括子节点。
#13
4
To collapse all use:
崩溃所有使用:
Ctrl + M and Ctrl+A
Ctrl+ M, Ctrl+A。
All shortcuts for VS 2012/2013/2015 available at http://visualstudioshortcuts.com/2013/
所有关于VS 2012/2013/2015的快捷方式都可以在http://visualstudioshortcuts.com/2013/上找到。
#14
2
In case of ugrading to Visual Studio 2010, 2012, 2013 or 2015, there's a Visual Studio extension to show current registered keyboard shortcuts, IntelliCommand.
在Visual Studio 2010、2012、2013或2015年,有一个Visual Studio扩展来显示当前注册的键盘快捷键,IntelliCommand。
#15
1
if you want to collapse and expand particular loop, if else then install following plugins for visual studio.
如果您想要崩溃并扩展特定的循环,如果还需要为visual studio安装以下插件。
#16
1
None of these worked for me. What I found was, in the editor, search the Keyboard Shortcuts
file for editor.foldRecursively
. That will give you the latest binding. In my case it was CMD + K, CMD + [.
这些都不适合我。我发现,在编辑器中,搜索编辑器的快捷键文件。这将给您最新的绑定。在我的例子中是CMD + K, CMD +[。
#17
0
Visual Studio can help you find the answer to your question in a couple of different ways.
Visual Studio可以通过几种不同的方式帮助您找到问题的答案。
Type Ctrl + Q to access Quick Launch, and then enter "collap". Quick Launch will display something like:†
键入Ctrl + Q以访问快速启动,然后输入“collap”。快速启动会显示一些类似的东西。
Menus (1)
Edit -> Outlining -> Collapse to Definitions (Ctrl+M, Ctrl+O)
NuGet Packages (1)
Search Online for NuGet Packages matching 'collap'
From there, enter "outlining" to find other menu entries related to outlining:
从那里,输入“提纲”,找到与提纲相关的其他菜单条目:
Menus (5)
Edit -> Outlining -> Toggle Outlining Expansion (Ctrl+M, Ctrl+M)
Edit -> Outlining -> Toggle All Outlining (Ctrl+M, Ctrl+L)
Edit -> Outlining -> Stop Outlining (Ctrl+M, Ctrl+P)
Edit -> Outlining -> Stop Hiding Current (Ctrl+M, Ctrl+U)
Edit -> Outlining -> Collapse to Definitions (Ctrl+M, Ctrl+O)
Options (4)
Text Editor -> Basic -> VB Specific (Change outline mode, Automatic inser...
...
However, note that Quick Launch will show you only those commands that are available as Visual Studio menu entries. To find other keyboard-related commands related to collapsing sections of code, in the Visual Studio menu bar click:
但是,请注意,快速启动只会显示那些作为Visual Studio菜单项可用的命令。在Visual Studio菜单栏中,要找到与代码崩溃相关的其他与键盘相关的命令,请单击:
Tools -> Options -> Environment -> Keyboard
This will display the keyboard section in the Options dialog box. In the "Show commands containing" text box, enter "edit.collap". Visual Studio will display a list that is something like:
这将显示选项对话框中的键盘部分。在“包含”文本框的“显示命令”中,输入“edit.collap”。Visual Studio会显示一个类似的列表:
Edit.CollapseAllincurrentblock
Edit.CollapseAllOutlining Ctrl+M, Ctrl+A (Text Editor)
Edit.CollapseBlockcurrentblock
Edit.CollapseCurrentRegion Ctrl+M, Ctrl+S (Text Editor)
Edit.CollapseTag Ctrl+M, Ctrl+T (Text Editor)
Edit.CollapsetoDefinitions Ctrl+M, Ctrl+O (Text Editor)
You'll need to click each command to see its associated keyboard shortcut.
您需要单击每个命令来查看其关联的快捷键。
† My examples taken from Visual Studio 2013.
从Visual Studio 2013中获得的例子。
#18
0
If you want to collapse/expand an area within a class/method (instead of collapsing the entire class/method), you may create custom regions as follow:
如果您想在类/方法中折叠/展开一个区域(而不是崩溃整个类/方法),您可以创建自定义区域如下:
#region AnyNameforCollapsableRegion
//Code to collapse
#endregion
参考:https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-region