Command to collapse all sections of code?

2019-01-02 19:19发布

In Visual Studio (2008) is there a command to collapse/expand all the sections of code in a file?

19条回答
刘海飞了
2楼-- · 2019-01-02 19:19

The following key combinations are used to do things:

CTRL + M + M → Collapse / Expand current preset area (e.g. Method)

CTRL + M + H → Collapse / Hide (Expand) current selection

CTRL + M + O → Collapse all(Collapse declaration bodies)

CTRL + M + A → Collapse all

CTRL + M + X → Expand all

CTRL + M + L → Toggle all

There some options in the context menu under Outlining.

查看更多
泛滥B
3楼-- · 2019-01-02 19:20

CTRL + M + O will collapse all.

CTRL + M + L will expand all. (in VS 2013 - Toggle All outlining)

CTRL + M + P will expand all and disable outlining.

CTRL + M + M will collapse/expand the current section.

CTRL + M + A will collapse all even in Html files.

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.)

enter image description here

查看更多
旧人旧事旧时光
4楼-- · 2019-01-02 19:23

In Visual Studio 2013:

CTL + M + A collapses all

CTL + M + L expands all

查看更多
梦醉为红颜
5楼-- · 2019-01-02 19:27

Ctrl+M expands region.

Ctrl+L collapses region.

查看更多
柔情千种
6楼-- · 2019-01-02 19:28

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"

查看更多
与君花间醉酒
7楼-- · 2019-01-02 19:28

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.

http://www.dev102.com/2008/05/06/11-more-visual-studio-shortcuts-you-should-know/

查看更多
登录 后发表回答