Skip to content

Tip 2.12: How to collapse and expand code

September 20, 2014

“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’

Sara Ford’s Blog

There are five commands for outline toggling; they can be found on the Edit–Outlining menu.

Toggle Outlining Expansion

By pressing Ctrl+M, Ctrl+M anywhere within the code block, you can toggle between collapsing a given block of code (as shown here)

and expanding it (as shown next)

Toggle All Outlining

By pressing Ctrl+M, Ctrl+L anywhere in the editor, you can toggle between collapsing and expanding the entire file.

Completely collapsed:

Completely expanded:

Stop Outlining

By pressing Ctrl+M, Ctrl+P anywhere in the editor, you can turn off outlining.

Start Automatic Outlining

Unfortunately, start outlining and stop outlining are not the same command, so
you can’t toggle between one state and the other. Additionally, using the
General Development Settings, start outlining is not bound to a keyboard
shortcut. So you need to go to Edit–Outlining–Start Automatic Outlining to turn
on outlining again.

Collapse to Definitions

In her opinion, Collapse To Definitions is the most useful of all the
outlining commands (mostly because it was the only one she used, except for when she
had to test the others). This command allows you to quickly glance at all of
your functions.

Happy Programming! =)

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: