如何在Visual Studio中崩溃所有的类?

时间:2021-07-19 01:34:08

Ctrl+M+O works really great to collapse all methods in a class however I have a hard time finding a way to collapse all classes outlining in the whole file.

Ctrl+M+O非常适合在一个类中折叠所有方法,但是我很难找到一种方法来折叠整个文件中列出的所有类。

One may ask - why do you have many classes in one file ? It's because I'm using MSpec and classes are my tests so I have files with tens of classes. In order to wrap my head around what is going on I often have to collapse classes one by one but that is not really efficient.

有人可能会问:为什么一个文件中有很多类?因为我使用的是MSpec,而类是我的测试,所以我有几十个类的文件。为了让我的头脑清醒过来,我经常会一个一个地崩溃,但这并不是很有效。

2 个解决方案

#1


49  

Ha -- well, apparently I just needed to offer a bounty before I would discover an answer minutes later.

哈——很显然,我只是需要提供一份赏金,我才会在几分钟后找到答案。

CtrlM, CtrlL will toggle all outlining. If anything in the file is collapsed, the first time you invoke this will expand everything and then invoking it again will collapse everything. This also collapses the namespace, which is a small inconvenience, but I'll call it progress.

按住ctrl, ctrl将会切换所有的大纲。如果文件中的任何内容都崩溃了,那么第一次调用它将会扩展所有内容,然后再次调用它将会崩溃所有东西。这也会破坏命名空间,这是一个小小的不便,但我将称之为进展。

#2


20  

The accepted answer is the roundabout way of doing it.

接受的答案是迂回的方式。

You're looking for Ctrl + M, A, which collapses all.

你要找的是Ctrl + M, A,它会崩溃。

As Jay mentioned, Ctrl + M, L expands all, but collapses all if already expanded.

正如Jay提到的,Ctrl + M, L扩展了所有,但是如果已经扩展了,就会崩溃。

#1


49  

Ha -- well, apparently I just needed to offer a bounty before I would discover an answer minutes later.

哈——很显然,我只是需要提供一份赏金,我才会在几分钟后找到答案。

CtrlM, CtrlL will toggle all outlining. If anything in the file is collapsed, the first time you invoke this will expand everything and then invoking it again will collapse everything. This also collapses the namespace, which is a small inconvenience, but I'll call it progress.

按住ctrl, ctrl将会切换所有的大纲。如果文件中的任何内容都崩溃了,那么第一次调用它将会扩展所有内容,然后再次调用它将会崩溃所有东西。这也会破坏命名空间,这是一个小小的不便,但我将称之为进展。

#2


20  

The accepted answer is the roundabout way of doing it.

接受的答案是迂回的方式。

You're looking for Ctrl + M, A, which collapses all.

你要找的是Ctrl + M, A,它会崩溃。

As Jay mentioned, Ctrl + M, L expands all, but collapses all if already expanded.

正如Jay提到的,Ctrl + M, L扩展了所有,但是如果已经扩展了,就会崩溃。