In one place so I don't have to look it all up (and invariably get the wrong app's shortcuts first) when I forget again

Code folding for Visual Studio 2019 (the old lady):

The following commands can be found on the Edit > Outlining submenu.

TABLE 1
NameDescription
Hide Selection(Ctrl+M, Ctrl+H) - Collapses a selected block of code that would not normally be available for outlining, for example an if block. To remove the custom region, use Stop Hiding Current (or Ctrl+M, Ctrl+U). Not available in Visual Basic.
Toggle Outlining Expansion(Ctrl+M, Ctrl+M) - Reverses the current hidden or expanded state of the innermost outlining section when the cursor lies in a nested collapsed section.
Toggle All Outlining(Ctrl+M, Ctrl+L) - Sets all regions to the same collapsed or expanded state. If some regions are expanded and some collapsed, then the collapsed regions are expanded.
Stop Outlining(Ctrl+M, Ctrl+P) - Removes all outlining information for the entire document.
Stop Hiding Current(Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic.
Collapse to Definitions(Ctrl+M, Ctrl+O) - Collapses the members of all types.
Collapse Block:<logical boundary>(C++) Collapses a region in the function containing the insertion point. For example, if the insertion point lies inside a loop, the loop is hidden.
Collapse All in: <logical structures>(C++) Collapses all the structures inside the function.

Code folding for Visual Studio Code (the upstart) from stackoverflow.com:

As of Visual Studio Code version 1.12.0, April 2017, see Basic Editing > Folding section in the docs.

The default keys are:

Fold All: CTRL+K, CTRL+0 (zero)

Fold Level [n]: CTRL+K, CTRL+[n]*

Unfold All: CTRL+K, CTRL+J

Fold Region: CTRL+K, CTRL+[

Unfold Region: CTRL+K, CTRL+]

*Fold Level: to fold all but the most outer classes, try CTRL+K, CTRL+1

Macs: use  instead of CTRL (thanks Prajeet)

Labels: , ,