GBB Logo         
GBB Services
GBB Services : Resources : Programming : Visual Studio .NET

Note: (written November 6 2016) I'm glad you found this essay I wrote long ago. It's archived here on my website, together with my other essays from a decade ago. If you want to see my more recent content, my blog is the place to find it.

Using Visual Studio .NET

by Walter Vannini

Introduction
Customizing the Visual C++ 7.1 environment
    No Start Page
    No Splash Page
    User Defined Key Words
    Timing Information
    Line Number Display
    Output Window Font
    Learning Mode
    Visual Assist
Useful features
    Scrolling
    Full Screen Mode
    Hiding Text
    Viewing White Space
    Viewing The Translation Unit
    Viewing The Include File Hierarchy
    Viewing The Full Path of a Source File
Shortcuts
    Window Navigation
    Other Shortcuts
Feedback

Introduction

I program in C++ using Visual Studio .NET for a living. I've customized my environment somewhat, and I've discovered some features that were not obvious to me when I started. This essay collects some of that information, both as a service to others, and as a reference and cheat sheet for myself. I hope it's useful to you.

Customizing the Visual C++ 7.1 environment

I am NOT a big believer in customizing Visual Studio. I often need to work on other people's systems, and I don't want to forget how to do things in the default environment. But, some customizations are so useful that I've made them anyway. A few of them are listed below.

No Start Page

I like to have Visual Studio start as fast as possible. That's why I change the "At Startup" default to: Tools/Options/Environment/General/At Startup/Show empty environment. Apparently loading the Start Page causes some unnecessary web-browsing components to be loaded, leading to a significantly longer startup time.

I learned about this (and lots of other useful information) from John Robbins' Bugslayer tips in MSDN magazine. This particular tip is tip 57 on page 135 of the November 2003 issue. Incidentally, tip 58 suggests improving Visual Studio performance by turning off tracking of the active item in the Solution Explorer. I find that tracking of the active item in a multi project solution to be extremely useful, so this is one tip I'm NOT going to follow.

No Splash Page

As I just mentioned, I like to have Visual Studio start as fast as possible. A splash page makes it seem like an application is starting faster (after all, you see something happening immediately) but the reality is that it slows things down. Fortunately, there's a command line option to get rid of the splash page.

The standard shortcut to devenv.exe has Target "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe". Change that to "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe" -nosplash, ie add the -nosplash command line argument, and the splash page will disappear. To make the corresponding change for Visual Studio 6, use "-nologo" instead of "-nosplash".

User Defined Key Words

One of the things I like to do is to have the Win32/MFC key words appear in red. If I'm using a name that's already being used by Microsoft, I want to know about it! I don't expect to win a name clash contest with Microsoft. It's also nice to have immediate confirmation that I remembered a Win32/MFC type correctly by seeing it change color when I finish typing it.

I achieve this by using the user defined keyword feature of the IDE (also available in Visual Studio 6). The relevant file is the ascii file "usertype.dat". It has to be placed in the same directory that devenv.exe lives in, which on my home machine is: "c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE". You can place any words you like in this file. To get the Win32 keywords, you can go to http://www.codeguru.com/tips/user_def_keywords.shtml. The relevant zip file is at http://www.codeguru.com/tips/user_def_keywords.zip This file is 181 Kb zipped and expands to 638 Kb.

The next time you start Visual Studio, the usertype.dat words will be used and colored differently. The default color is blue. I prefer red, so I always change it via Tools/Options/Environment/Fonts and Colors/Display Items/User Keyword

Timing Information

For various reasons, I like to know how long my builds take. This is done via Tools/Options/Projects/VC++ Build/Build Timing/Yes

If you want to do this with Visual Studio 6, start it off using "msdev.exe -y3" rather than "msdev.exe".

Line Number Display

I like to be able to see the line numbers. This is done via Tools/Options/Text Editor/"C/C++"/General/Display/Line Numbers

Output Window Font

I like fixed width fonts, like "Courier New", for my source windows. Vertical alignment communicates useful information to me. But for other windows, like the Output window, this is not needed, and is even inappropriate, since it makes the total width of lines needlessly long, leading to the need for horizontal scrolling. The setting to change is at Tools/Options/Environment/Fonts and Colors/Show Settings For/ Test Output Tool Windows/Font/ Change from the default "Courier New" to "Times New Roman".

John Brewer , an extremely knowledgeable independent contractor whom I've met at various programmer user groups, told me that the Times newspaper of London developed the Times Roman font so as to squeeze in more words per row of text. Since this is just what I want to achieve with the output window, I go with the Times Roman font.

Learning Mode

The setting Tools/Customize/Options/"Show Shortcut Keys in Tooltips" allows me to learn about the many shortcuts available to me.

Visual Assist

This one's a little different from the previous items: it's not free. The last time I looked, the price for a Visual Assist .NET 7.1 license was $79. The current details are at http://www.wholetomato.com/ . I've found that Visual Assist has quickly paid for itself. Even without the economic incentive, I'd get Visual Assist just because it makes the programming experience more enjoyable.

The three main features I use are:

1.alt-o to switch between .cpp/.c files and .h files.
2.a visual display of the 80 character width margin of a source file.
3.the goto button in the "show context and definition window"

I customize Visual Assist by:

1.Placing the "show context and definition window" at the bottom of the source window, rather than the top.
2.Displaying the column indicator (it's off by default).
3.Using column 80 rather than column 75 for the column indicator display.
4.Turning OFF the enhanced syntax coloring (I just don't find it that helpful, especially since I use the user defined keyword feature described above).
5.Turning OFF the correction of "converting . to -> when appropriate" (It just gets in the way when working with smart pointers, and I like to use the various boost smart pointers).

Wayne Vucenic, an independent contractor whom I'd recommend without reservation, turned me onto Visual Assist. Here's excerpts from an email he sent me way back in October of 2001:

"For the last few months, I've been using an add-on for Visual C++ 6 called Visual Assist (http://www.wholetomato.com). It adds 50 or more useful features to the VC++ IDE. ...
Many of the features are things that I've been wishing VC++ had for years. For example, a toolbar button (that initially shows up on the new Visual Assist toolbar, but like all such buttons, it can be dragged onto a different toolbar, if you wish) that opens the matching .cpp or .h file. If the top window contains foo.cpp, clicking the button will open foo.h, and vice versa. This feature alone saves me about 5 minutes every day. ...
In my opinion, anyone who spends most of their day using VC++ who doesn't use Visual Assist is simply working too hard."

Another person who recommends "Visual Assist" is John Robbins of Wintellect. He's a working contractor, and is the author of the BugSlayer column for MSDN magazine, and also the author of two excellent books on debugging in the windows environment. I strongly recommend reading anything he writes.

Disclaimer: I have no business interest in Whole Tomato software. I'm just a satisfied customer.

Useful features

I'm not going to waste space enumerating all the features of Visual Studio .NET (assuming that I could!). Instead, I'm going to focus on some features that I've found useful, that were not immediately obvious to me, and that weren't covered in the customization section above.

Scrolling

I'm a little embarrassed to admit that I wasn't aware that you can scroll the page up and down (as opposed to the cursor) by using "ctrl uparrow" and "ctrl downarrow". Just in case you might have missed it also, I'm mentioning it here.

Full Screen Mode

Using "shift-alt-enter" toggles full screen mode. This is quite handy for editing source files. As far as I know, visual studio 6 doesn't have it.

Hiding Text

With "outlining" (also known as line folding) you can hide a logical block of code by clicking on the outline box. I wasn't aware until recently that you can hide ANY selected lines of text you want by using the keyboard shortcut ctrl-MH. This can be useful if you're simultaneously editing two sections of a file that are several screens apart. When you're done, you can unhide the lines using ctrl-MU.

Incidentally, a trick for hiding comments is to make them the same color as the background. Just go to Tools/Options/Environment/Fonts and Colors/Display Items/Comments and make the foreground color the same as the background color. On my home machine, that means making the foreground white. Now you can read the code without being distracted by comments! I've never needed to do this, but it's nice to know I can.

Viewing White Space

Sometimes I want to view the whitespace (spaces and tabs). This can be toggled via menus: Edit/Advanced/View White Space, or via the keyboard shortcut ctrl-RW.

In Visual Studio 6, the shortcut is ctrl-shift-8

Viewing The Translation Unit

Conceptually, compiling a source file is done in (at least) two stages:

1. Applying all preprocessor directives (especially header file inclusion) to create a source file that contains no preprocessor directives (this file is known as the translation unit)
2. Compiling of the self contained translation unit to an object file

To view the translation unit, you need to change the properties of the .cpp file. Go to Configuration Properties/"C/C++"/Preprocessor/Generate Preprocessed File and change "No" to "Without Line Numbers". Don't forget to change it back to "No" when you're done! Incidentally, the preprocessed file for "abc.cpp" will be "abc.i".

Viewing The Include File Hierarchy

Sometimes I want to see which include files have been used in compiling a .cpp file. This wasn't possible with Visual Studio 6. With Visual Studio .NET, not only can you see which files were used and in what order, but the display is indented appropriately. Very nice!

Go to Configuration Properties/"C/C++"/Advanced/Show Includes and change "No" to "Yes". Look in the output window, after compiling the file of course, to see the result.

Viewing The Full Path of a Source File

It took me a long time to learn how to do this. Earlier this year I had lunch with the author of a book dealing with the Visual Studio .NET environment. I asked him how to do it, and he didn't know. He'd never needed to do it! I'll protect the guilty and not mention his name, or his book. The book is NOT "Inside Microsoft Visual Studio .NET", which I think is a good book with lots of useful information. If I ever need to write an add-in, I'll be referring to it.

The information is definitely not available by bringing up the property page! As far as I know, the only way to do it is by waiting for the tooltip triggered by letting the mouse hover over the tab associated with the source file. This means that the "Tabbed Documents" setting has to be in use, rather than the "MDI environment" setting. If it weren't for this feature, I would work in the "MDI environment" mode. To check which setting you're using, navigate to Tools/Options/Environment/General. The two mutually exclusive radio buttons you should now see are "Tabbed Documents" and "MDI environment".

Shortcuts

There are far more useful keyboard shortcuts in Visual Studio .NET than there were in Visual Studio 6, and I think it's worth learning some of them. I've listed a few of the ones I use (or should use!)

I kind of like the "goto last edit" via "ctrl zy" technique: ctrl-z undoes the last edit, then ctrl-y (or ctrl-shift z) reapplies the last edit, and the cursor is positioned at the edit location. Hey, can I patent that?

Window Navigation

You can do a lot without the mouse!

When editing, the following shortcuts are very handy:

goto the active document ESC
goto another document ctrl F6 (and ctrl-shift F6)
goto the solution window ctrl-alt L
goto the class view window ctrl-shift C
goto the output window ctrl-alt o
goto the task list window ctrl-alt K
CLOSE the active document ctrl F4
TOGGLE the .cpp and .h files alt o (with Visual Assist!)

When debugging, the following shortcuts also become available:

goto the callstack window ctrl-alt C
goto the quickwatch window ctrl-alt q
goto the watch window ctrl-alt W1 (that's a one, not an ell)

Other Shortcuts

Some more navigation shortcuts

scroll the page down a line ctrl downarrow
scroll the page up a line ctrl uparrow
move the cursor down a line downarrow
move the cursor up a line uparrow
goto line 1 ctrl home
goto line 42 ctrl g 42 ReturnKey
goto the last line ctrl end
goto the last edit ctrl zy
search ctrl f
incremental search ctrl i
find the next item F3
find the previous item shift-F3
goto the next item F8 (used to be F4 in Visual Studio 6)
goto the previous item shift-F8 (used to be shift-F4 in Visual Studio 6)

There are the following source viewing shortcuts:

toggle whitespace display ctrl rw
hide selection ctrl mh
unhide selection ctrl mu

Here's some more useful shortcuts:

comment selection ctrl kc
uncomment selection ctrl ku
to uppercase ctrl-shift U
to lowercase ctrl u
build solution ctrl-shift B
compile the active file ctrl F7
find in files ctrl-shift F
replace ctrl h

Feedback

If you have corrections, additions, modifications, etc please let me know mailto:walterv@gbbservices.com

Back to top of page