Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's WebLog


My adventures embracing open source on CodePlex and at Microsoft

News

Did you know... how to collapse and expand code? - #035

D'oh!  I had this tip set to go out at 3pm PST instead of 3am PST.  Apologies for the delay!

Yesterday's tip talked about how to cut a collapsed block of code, but how do you collapse a block of code anyways?

There are basically five commands for "outline toggling," which can be found on the Edit - Outlining menu.

#1 - Toggle Outlining Expansion

Toggle Outlining Expansion menu item

By Pressing Ctrl+M, Ctrl+M anywhere within the code block, you can toggle between expanding and collapsing the given block of code.

Toggle Outlining Expansion Example

#2 -  Toggle All Outlining

Toggle All Outlining menu item

By Pressing Ctrl+M, Ctrl+L anywhere in the editor, you can toggle between expanding and collapsing the entire file.  When completely collapsed, you can then drill down into the section of code you are most interested in.  When completely expanded, you can view all code without having to expand any sections.

Toggle All Outlining Example

#3 - Stop Outlining

Stop Outlining menu item

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

Stop Outlining Example

#4 - Start Outlining

StartAutomaticOutlining

Unfortunately, start 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 is not bound to a keyboard shortcut.  So, you will need to go to Edit - Outlining - Start Automatic Outlining to turn on outlining again.

 StartAutomaticOutliningExample

#5 - Collapse to Definitions

Collapse To Defintions

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

Collapse To Defintions Example

Lastly, if these keyboard shortcuts don't match what you have, it is because you are using a different set of default settings that you chose on your first launch of Visual Studio.  I'm using the General Development Settings for all these tips.

Technorati tags: ,
Posted: Wednesday, September 12, 2007 3:00 AM by saraford

Comments

Jason Haley said:

# September 13, 2007 10:31 AM

.NET Geek said:

For some time I have been subscribing to Sara Ford's blog where she shares useful tips for Visual

# October 9, 2007 5:55 AM

Sara Ford's WebLog said:

Yesterday's tip was everything you ever wanted to know about outlining in the editor. Today, we'll explore

# January 15, 2008 12:39 AM

Visual Studio 2008 ワンポイント said:

昨日のワンポイント はエディタでのアウトラインの表示についてでした。今日はアウトラインのカスタマイズについてご紹介します。 [ツール] メニューの [オプション] をクリックし、[テキスト エディタ]

# July 7, 2008 3:59 AM

Visual Studio 2008 ワンポイント said:

この記事を 3:00 AM PST に公開するつもりだったのに、3:00 PM PST に設定していました。遅くなって申し訳ありません。 昨日のワンポイント では、折りたたまれたコード ブロックを切り取る方法をご紹介しました。では、コード

# July 7, 2008 4:00 AM
New Comments to this post are disabled
Page view tracker