Wouldn’t it be great if you had the ability to make all the other code in the text editor disappear, so that you could just focus on the one method you are working on?
That would be really cool. Unfortunately I have no idea how to do that. But I can show you the next closest thing….outlining!
Open up Visual Studio 2005, and create a brand new Windows Application Project.
Expand the Form1.cs file in the Solution Explorer, and open up the Form1.Designer.cs file.
You’ll see there is some grey text at the bottom of the screen “Windows Form Designer generated code.” Hmm, let’s see what type of code was generated.
CTRL + M, then CTRL + P
You should see that the whole file is now visible — all outlining has been removed. Cool. Next let’s collapse the whole file down.
CTRL + M, then CTRL + O
That’s a letter O by the way. Now you should see a very clean higher level view of what’s contained in the file. Next to each region you’ll see a + that you can use to expand the region. Don’t reach for the mouse yet. Since this is a keyboard tip, we should really review the keyboard shortcut to expand and collapse a region.
Move to line 23 (CTRL + G, then enter 23). You should be on the “Windows Form Designer generated code.”
CTRL + M, then CTRL + M
That region should have expanded. Now move to line 29 (CTRL + G, then enter 29). You should now be on the InitializeComponent method.
CTRL + M, then CTRL + M
The region expands. If you enter the same keyboard combinations again, the region collapses.
One last tip. Let’s expand the whole document again.
CTRL + M, then CTRL + P
Move to line 32 (CTRL + G, then enter 32). Select the text on line 32 and 33.
CTRL + M, then CTRL + H
Pretty cool, huh? Those two selected lines have now been collapsed inside the method down to an ellipsis. This only works in C#, there is no other outlining being done in the whole file, and text is selected.
Post a Comment