|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
Customizing the Visual C++ 7.1 environment
No Start Page
No Splash Page
User Defined Key Words
Line Number Display
Output Window Font
Full Screen Mode
Viewing White Space
Viewing The Translation Unit
Viewing The Include File Hierarchy
Viewing The Full Path of a Source File
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.
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.
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.
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".
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
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".
I like to be able to see the line numbers. This is done via Tools/Options/Text Editor/"C/C++"/General/Display/Line Numbers
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.
The setting Tools/Customize/Options/"Show Shortcut Keys in Tooltips" allows me to learn about the many shortcuts available to me.
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:
I customize Visual Assist by:
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:
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.
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.
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.
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.
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.
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
Conceptually, compiling a source file is done in (at least) two stages:
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".
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.
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".
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?
You can do a lot without the mouse!
When editing, the following shortcuts are very handy:
When debugging, the following shortcuts also become available:
Some more navigation shortcuts
There are the following source viewing shortcuts:
Here's some more useful shortcuts:
If you have corrections, additions, modifications, etc please let me know mailto:email@example.com