
Collapse and Expand Your Code #97
Chapter 13, Enhancing Visual Studio
|
437
HACK
HACK
#97
Collapse and Expand Your Code Hack #97
Collapsing and expanding regions can be fun, but there’s a free add-in that
lets you do the same with If, Try, and With statements.
Classify is a Visual Studio .NET add-in that exposes a new toolbar and new
context sensitive menu items when editing source code. Classify is largely
compatible with C#, though some features are currently specific to Visual
Basic .NET. Classify can be downloaded from http://www.visualstudiohacks.
com/classify.
The goal of the add-in is to simplify basic coding tasks and to assist in the
common aim of any good programmer, which is to make code readable and
maintainable.
To assist with readability, Visual Studio .NET has a feature that enables you
to collapse, or temporarily hide, sections of code. However, by default, this
behavior applies only to basic code blocks like regions, subroutines, and
enumeration blocks. What Classify does, for Visual Basic .NET, is take this
to the next level.
Auto-Collapse and Scan-Collapse are very similar features, in that they col-
lapse code. Auto-Collapse is invoked at will by the user in each location
where code is to be hidden. Scan-Collapse automatically scans the current
source file and collapses all sections of code that the programmer is likely to
want to collapse.
For example, imagine that you have a subroutine ...