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
By Pressing Ctrl+M, Ctrl+M anywhere within the code block, you can toggle between expanding and collapsing the given block of code.
#2 - Toggle All Outlining
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.
#3 – Stop Outlining
By Pressing Ctrl+M, Ctrl+P anywhere in the editor, you can turn off outlining.
#4 – Start Outlining
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.
#5 – Collapse to Definitions
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.
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: VS2005Tip, VS2008Tip