Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to collapse/unfold by levels in Visual Studio?

Tags:

I would like to know if there exists some way to collapse and unfold by levels in Visual Studio. I already know these keys:

  • CTRL-M, O: collapse all
  • CTRL-M, O: unfold all
  • CTRL-M, M: toggle

They work, but they collapse and unfold to the maximum possible level. I want for example unfold at lvl 2, lvl 3 depth, then collapse to lvl 1, etc.

An example of this functionality exists in Notepad++ editor:

  • ALT-n: collapse level n
  • SHIFT-ALT-n: unfold to level n

If this functionality is provided by an extension, it'd be good to know the name of this extension.

like image 432
mjsr Avatar asked Mar 20 '11 07:03

mjsr


People also ask

How do I create a collapsible section in Visual Studio?

Select the section of code. Press Ctrl+M+H – Turn on the collapsible/expandable option.

How do I collapse all sections in Visual Studio?

(Ctrl+M, Ctrl+P) - Removes all outlining information for the entire document. (Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic. (Ctrl+M, Ctrl+O) - Collapses the members of all types.

How do you collapse a code in Visual Studio?

In VSCode terminology, the collapsible code blocks feature is called Fold/Unfold. You can quickly fold a block of code, given that your cursor is placed inside of it by pressing Ctrl+Shift+[ keyboard combination. Similar to that, Ctrl+Shift+] key combination will unfold the collapsed region at the cursor.

How do you collapse all regions in Visual Studio code?

Use Shift + Click on the folding icon to fold or unfold the region and all regions inside. You can also use the following actions: Fold (Ctrl+Shift+[) folds the innermost uncollapsed region at the cursor.


1 Answers

It's useful to note that, if you first do Collapse All Outlining (Ctrl+M, A), then you can expand/collapse regions one level at a time, for example by using the mouse or the Toggle Outlining Expansion shortcut (Ctrl+M, M). Not as good as expanding/collapsing by n levels, but better than nothing.

like image 198
Telmo A. Avatar answered Oct 19 '22 14:10

Telmo A.