Discover Hidden Tips and Tricks of Visual Studio 2008
Customize Your Development Environment
The Options dialog box of Visual Studio (shown in Figure 1) can be invoked from the Tools dropdown menu. You can think of this dialog box as a tabbed interface, with the tabs running vertically along the left side. The initial tab that appears (General) allows developers to toggle between a tabbed Single Document Interface (SDI) and a Multiple Document Interface (MDI) development environment. While the default Single Document Interface is generally considered to be the most modern approach, Visual Basic 6 developers will find the Multiple Document Interface s floating code windows to be more familiar (see Figure 2).
Figure 1: Visual Studio 2008 s Options dialog box.
Figure 2: Visual Basic 6 developers will find the Multiple Document Interface option to be familiar.
The Recent files area also can be quite useful for commanding Visual Studio to remember more recent projects and files than it normally would. These recently used projects are listed on the Visual Studio Start Page, as well as the File dropdown menu.
The Fonts and Colors tab could easily keep a developer entertained for hours with the thousands of options it contains for dramatically altering the visual appearance of virtually every aspect of Visual Studio (see Figure 3). Every window and nearly every character can be independently adjusted. For example, in an HTML code window, you can independently configure brackets, elements, attributes, comments, tag delimiters, and more. Individual windows can be adjusted independently, as well; the immediate window, output window, query editor, and command window are just a few of the more than two dozen windows that can be configured.
Figure 3: Stuck in a rut? Spice up your development environment by tinkering with the fonts and colors of your code windows.
Being well into the information age, it s no surprise that Visual Studio provides an abundance of options for fine tuning our online queries for programming help. Some developers may appreciate Visual Studio s ability to leverage the always-up-to-date online MSDN Library for help, instead of consuming potentially precious hard drive space with such voluminous texts. On the other hand, those lucky enough to have abundant disk space may prefer to leverage such a speedy data source instead of a potentially lagging (or sometimes non-existent) Internet connection.
In addition to the love/hate relationship we ve all had with MSDN s classic help system, more recent versions of Visual Studio allow a variety of top-notch .NET development Web sites to be simultaneously searched, as well. ASPAlliance.com, 4GuysFromRolla.com, and DotNetJunkies.com are just a few of the many Web sites listed in the default options shown in Figure 4. Unfortunately, there is currently no way to customize the list with new Web sites of your own choosing.
Figure 4: Ensure you always get help when you need it by adjusting Visual Studio s help options.
Start Me Up
The Start tab also has some interesting options. By default when Visual Studio is opened, its standard Start Page is displayed with news links listed from an MSDN RSS feed. You can customize Visual Studio to list an alternate RSS feed of your own choosing via the Start Page news channel textbox shown in Figure 5. Alternatively, the standard start page can be skipped altogether to speed up Visual Studio s load time. To save yet another step, Visual Studio can be configured to automatically open the last solution with which you were working, or to open the new/load project dialog box.
Figure 5: Optimize Visual Studio load times by adjusting its start-up options.
The Projects and Solutions tab is useful for configuring the default paths for projects and templates. Another little known gem on this tab is the Save new projects when created checkbox (see Figure 6). By turning it off, you no longer need to pick a project filename and location when initially creating a project. This is highly useful for situations where you re just tinkering with a throw-away project and you don t want to gum up your hard drive with code scraps. With this option turned off, Visual Studio will store all the project s files in a temporary location unless, and until, you decide to explicitly save the project.
Figure 6: Adjust Visual Studio s default paths via the Projects and Solutions option tab.
Variable Type Inference
Visual Basic developers have a few default project settings all to themselves. Figure 7 shows these options, some of which are familiar to old-school Visual Basic developers. For example, Option Explicit is used to ensure variables are explicitly declared before they are used. A compile error is thrown if undeclared variables are used when Option Explicit is set to True; otherwise, implicit type declarations are inferred. While type inference had been shunned for a number of years, it has recently come back into style, and is accepted even by C# programmers. Therefore, VB 2008 introduced a new option: Option Infer. When Option Infer is set to its default value of True (and Option Explicit is also set to its default value of True), variables must be declared before they can be used but the variable type can be automatically inferred.
Figure 7: Visual Basic developers have a few project default options all to themselves.
Option Strict helps minimize the chance of run-time conversion errors by verifying valid variable conversions at compile time. Option Compare is used to specify whether string comparisons should be case-sensitive or not. Its default value of Binary specifies that string comparisons should be case-sensitive, while setting it to Text specifies case-insensitivity should be employed.
A variety of source control options are available to ease your file management chores (see Figure 8). Visual Studio can be set to automatically get all the latest files upon project load. Likewise, it also can be set to automatically check in every file when a project is closed. More obscure options are available, as well, such as keeping files checked out when checking in changes, or allowing checked-in files to be edited.
Figure 8: Default source control options can be configured for Visual SourceSafe and Team Foundation Server.
Text Editor Options
Visual Studio s text editing features can be adjusted globally or independently for each language and/or editor. For example, you can have different editing options for Visual Basic, C#, HTML, XML, XAML, SQL, etc. Or, they can all be set globally and simultaneously from the Text Editor tab shown in Figure 9.
Figure 9: Line numbers and word wrapping can be configured globally or for each individual editor.
Visual Studio s beloved statement completion options also can be configured here. Line numbers can be turned on from this location also, as shown at the left side of Figure 10. Word wrapping also can be enabled so that side-to-side scrolling in Visual Studio is never necessary. When word wrapping is enabled, an optional glyph (shown at the right side of Figure 10) can be enabled to visually indicate a wrapped line.
Figure 10: The line numbers on the left and word wrapping glyph on the right can be enabled from the options shown in Figure 9.
Web developers will likely find the HTML-specific text editor tab shown in Figure 11 to be of particular use. One of my personal favorites is the Insert attribute value quotes when typing checkbox. Simply by enabling this textbox (which is disabled by default), you can save tons of time if you do a lot of manual HTML editing. After you type the equals sign for an HTML attribute, quotes will automatically be inserted in the correct place so you can continue typing the attribute value smoothly, without having to worry about such annoying little details.
Figure 11: The HTML Format tab is especially useful for Web developers.
The Tag Specific Options button opens an even more impressive dialog box (shown in Figure 12) that is useful for configuring the default display of many common HTML elements and ASP.NET Web controls. Coloring, indents, line breaks, and tag-specific options can all be configured here.
Figure 12: HTML elements and ASP.NET Web controls can have their defaults set in the Tag Specific Options tab.
Web Developers should also find the HTML Designer tab to be especially useful (see Figure 13). From here you can specify whether Visual Studio should initially open Web pages in HTML view, the designer view, or split pane view. HTML view typically opens the quickest, while design view and HTML view are arguably more user friendly.
Figure 13: Visual Studio s HTML Designer has many options of particular interest to ASP.NET developers.
Figure 14 illustrates a handy feature of which few developers are aware. Split View (first introduced with Visual Studio 2008) can optionally be split vertically instead of the horizontal default. This can be an efficient use of screen real-estate for those developers lucky enough to have one of those increasingly popular wide-screen monitors.
Figure 14: Visual Studio 2008 s new split view can optionally be split vertically.
Those of you with Visual Studio Team System Test Edition will have the Test Tools tab shown in Figure 15. From this tab you can configure a variety of unit testing capabilities, such as source code coloring. With this feature enabled, and after executing a set of tests, you can see specifically which lines of code were executed because they ll be highlighted in a different color than the lines of code that were not exercised. This can be a handy way to ensure critical code areas have been thoroughly tested under varying circumstances.
Figure 15: Visual Studio Team System Test Edition provides a set of options that can help you thoroughly unit test your code.
The checkbox shown at the bottom of Figure 15 can be a useful shortcut for quickly getting to the bottom of a failed unit test. When this checkbox is checked, you can simply double-click on a failed test in Visual Studio 2008 to be taken directly to the line of code that caused the failure.
Windows Forms Options
Developers still creating Windows forms applications will likely find the Data UI Customization tab to be a time-saver when employing data binding techniques (see Figure 16). This tab specifies what kinds of controls should automatically be associated with particular kinds of data. For example, string variables are typically represented by Labels or TextBoxes for single values, or sometimes ListBoxes or ComboBoxes in cases where lists of strings are represented.
Figure 16: Data binding defaults can be configured from this Data UI Customization dialog box.
Of course, this tab allows complete customization of such data binding options so you could instead represent strings with a RichTextBox control, for example. In case the default list of more than 50 controls isn t enough for your taste, the list can be customized with additional controls of your own choosing.
You may find a few more or less options in your Visual Studio installation than you ve seen here depending on which optional components you ve installed. For example, the various Visual Studio team editions each add their own option sections, as does Visual Studio Tools for Office.
As with most professions, it pays to be intimately familiar with the tools of your trade. Visual Studio is a highly powerful development environment that gets even more powerful once you ve learned to tame its many options. You should now have a more thorough understanding of Visual Studio s capabilities so you can take your development experience to the next level.
Steve C. Orr is an ASPInsider, MCSD, Certified ScrumMaster, Microsoft MVP in ASP.NET, and author of Beginning ASP.NET 2.0 AJAX by Wrox. He s been developing software solutions for leading companies in the Seattle area for more than a decade. When he s not busy designing software systems or writing about them, he can often be found loitering at local user groups and habitually lurking in the ASP.NET newsgroup. Find out more about him at http://SteveOrr.net or e-mail him at mailto:Steve@SteveOrr.net.