Visual Studio .NET - Outlining
(Page 6 of 10 )
Visual Studio .NET allows you to outline, or collapse and expand, sections of your code to make it easier to view the overall structure. When a section is collapsed, it appears with a plus sign in a box along the left edge of the code window (
) Clicking on the plus sign expands the region.
You can nest the outlined regions, so that one section can contain one or more other collapsed sections. There are several commands to facilitate outlining, shown in Table 2-3.
| Table 2-3. Outlining commands | |
|---|
| Command | Key combination | Description |
|---|
| Hide Selection | Ctrl+M, Ctrl+H | Collapses currently selected text. In C# only, this command is visible only when automatic outlining is turned off or the Stop Outlining command is selected. |
|---|
| Toggle Outlining Expansion | Ctrl+M, Ctrl+M | Reverses the current outlining state of the innermost section in which the cursor lies. |
|---|
| Toggle All Outlining | Ctrl+M, Ctrl+L | Sets all sections to the same outlining state. If some sections are expanded and some collapsed, then all become collapsed. |
|---|
| Stop Outlining | Ctrl+M, Ctrl+P | Expands all sections. Removes the outlining symbols from view. |
|---|
| Stop Hiding Current | Ctrl+M, Ctrl+U | Removes outlining information for currently selected section. In C# only, this command is visible only when automatic outlining is turned off or the Stop Outliningcommand is selected. |
|---|
| Collapse to Definitions | Ctrl+M, Ctrl+O | Automatically creates sections for each procedure in the code window and collapses them all. |
|---|
| Start Automatic Outlining | n.a. | Restarts automatic outlining after it has been stopped. |
|---|
| Collapse Block | n.a. | In C++ only, similar to Collapse to Definitions, except applies only to the region of code containing the cursor. |
|---|
| Collapse All In | n.a. | In C++ only, same as Collapse Block, except recursively collapses all logical structures in a function in a single step. |
|---|
The default behavior of outlining can be set using the Tools -> Options menu item. Go to Text Editor, then the specific language for which you want to set the options. The outlining options can be set for VB .NET under Basic -> VB Specific, for C# under C# -> Formatting, and for C++ under C/C++ -> Formatting.
IntelliSense Microsoft Intellisense technology makes the lives of programmers much easier. It has real-time, context-sensitive help available, which appears right under your cursor. Code completion automatically completes your thoughts for you, drastically reducing your typing. Drop-down-lists provide all methods and properties possible in the current context, available at a keystroke or mouse click.
What’s not to love? Intellisense does make up for a lot of Visual Studio .NET’s more, shall we say, exasperating traits.
The default Intellisense features can be configured by going to Tools -> Options and then the language-specific pages under Text Editor.
Most of the Intellisense features appear as you type inside a code window, or allow the mouse to hover over a portion of the code. In addition, the Edit -> Intellisense menu item offers the commands shown in Table 2-4.
| Table 2-4. Intellisense commands |
|---|
| Command | Key combination | Description |
|---|
| List Members | Ctrl+J | Displays a list of all possible members available for the current context. |
|---|
| Keystrokes incrementally search the list. Press any key to insert the high |
|---|
| lighted selection into your code; that key becomes the next character after |
|---|
| the inserted name. Use the Tab key to select without entering any addi |
|---|
| tional characters. |
|---|
| This can also be accessed by right-clicking and selecting List Member from |
|---|
| the context-sensitive menu. |
|---|
| Parameter Info | Ctrl+Shift+Space | Displays a list of number, names, and types of parameters required for a |
|---|
| method, sub, function, or attribute. |
|---|
| Quick Info | Ctrl+K, Ctrl+I | Displays the complete declaration for any identifier (e.g., variable name or |
|---|
| class name) in your code. This is also enabled by hovering the mouse cur |
|---|
| sor over any identifier. |
|---|
| Complete Word | Alt+Right Arrow or | Automatically completes the typing of any identifier once you type in |
|---|
| Ctrl+Space | enough characters to uniquely identify it. This only works if the identifier is |
|---|
| being entered in a valid location in the code. |
|---|
The member list presents itself when you type the dot following any class or member name.
Every member of the class is listed, and each member’s type is indicated by an icon. There are icons for methods, fields, properties, events and so forth. In addition, each icon may have a second icon overlaid to indicate the accessibility of the member: public, private, protected, and so on. If there is no accessibility icon, then the member is public.
If the member list does not appear, you will want to ensure that you have added all the necessary using (or imports) statements. You’ll also want to remember that Intellisense is case-sensitive in C#. Also, occasionally C# needs a rebuild before it will reflect the most recent changes.
Table 2-5 lists all the different icons used in the member lists and other windows throughout the IDE. The accessibility icons are listed in Table 2-6.
*****************************************************
Table 2-5. Object icons
Icon Member type
Class
Constant
Delegate
Enum
Enum item
Event
Table 2-5. Object icons (continued)
Icon Member type Exception Global Interface
Intrinsic Macro Map Map item Method or Function Module Namespace Operator Property Structure Template Typedef Union Unknown or Error Variable or Field
Table 2-6. Object accessibility icons
Icon Accessibility type Shortcut Friend Internal Private Protected
*****************************************************
View Menu
The View menu is a context-sensitive menu that provides access to the myriad of windows available in the Visual Studio .NET IDE. You will probably keep many of these windows open all the time, others you will use rarely, if at all.
The View menu is context-sensitive. For example if your form has no controls on it the Tab Order submenu will be grayed out.
When the application is running, a number of other windows become visible or available. These windows are accessed via the Debug -> Windows menu item, not from the View menu item.
Visual Studio .NET can store several different window layouts. In particular, it remembers a completely different set of open windows during debug sessions than it does during normal editing. These layouts are stored per-user, not per-project or per-solution.
This section discusses those areas that may not be self explanatory.
This article is excerpted from Programming ASP.NET by Jesse Liberty and Dan Hurwitz(O'Reilly, 2003; ISBN 0596004877). Check it out at your favorite bookstore today. Buy this book now. |
Next: Open and Open With . . . >>
More ASP.NET Articles
More By O'Reilly Media