Viewing stl maps, strings and vectors in Visual Studio’s debugging windows

The debugging windows (Locals, Autos, and Watch windows) have been modified in Visual Studio 2010 to show a couple of important properties of standard template library (STL) map, vector, and string types.

In Visual Studio 2008, STL maps only showed keys and values in the debugger windows. Now, the comp (or comparer) property is now visible to show what comparer is used in the current variable instance shown in the debugger window as seen below.

stl::map in VS2008 debugger window

stl::map in VS2008 debugger window

stl::map in VS2010 debugger window

stl::map in VS2010 debugger window

For vectors, VS 2010 shows the capacity and size properties as the following image illustrates.

stl::vector in VS2008 debugger window

stl::vector in VS2008 debugger window


stl::vector in VS2010 debugger window

stl::vector in VS2010 debugger window

And finally, strings now show separate properties for size and capacity. As you can see, this is much better that the Visual Studio 2008 version where these properties were bunched up as a value for the [actual members] property. Even when drilling down this property, you are left with something like the properties _Bx, _Mysize, and _Myres.

std::string in VS2008 debugger window

std::string in VS2008 debugger window


std::string in VS2010 debugger window

std::string in VS2010 debugger window

Making square selections

In visual Studio 2008, you had the possibility of selecting columns of data, which I call square selections (a.k.a box selection, column selection, etc), as opposed to full row selection as seen in the following image.

Normal text selection

Normal text selection

Square Text Selection

Square Text Selection

Unfortunately, this was of limited usage since you were not able to replace text by typing once you’ve made your selection. Visual Studio 2010 opens up new possibilities.

What has really changed in Visual Studio 2010 is that after making a square selection, you can replace the selected text simultaneously on all selected rows, whether it be by typing or by pasting previously selected text. If you are going to paste text into the selection, make sure that you have the same number of lines in the clipboard or the pasted text will overflow to lines below the selection.

Multiline typing

Multiline typing

Pasting a square select text
1. Copy text to the clipboard by first selecting the text by holding down the ALT key and then making a selection using the mouse.
2. Press Ctrl+C to copy the text to the clipboard.
3. Make a new selection where you wish to copy the text.
4. Press Ctrl+V to paste the text.

I’ve purposely copied one too many lines (3 lines of “public” in the following image) and copied it to the block of two lines above. You can see that an extra line of with only public was pasted.

Pasting Square Selection of Text

Pasting Square Selection of Text

Include files more easily..with VS 2010

C++ developers will rejoice when they see how to include files in a c++ project in Visual Studio 2010. Two great new features will surely save you valuable time: Intellisense and External Dependencies

Have you ever wished that you could open a file search dialog box straight from the line where you want to include a file? Imagine a small button with three dots right on a line in an open file… well, that’s not really what has been added, but what they’ve done is not bad.

Intellisense
We all know that there are includes that use the <> symbols, i.e. #include <vector> and others with quotes, i.e. #include “myinclude.h”, used with global includes and local project includes, respectfully. Now, Visual Studio 2010 will help you find files by listing them as you type. For example, if you type #include “, a list of files available in the current project will be shown as in the image below.

Typing #include and a quote

When you type #include < another list of files is shown to let you choose a global include file. In both cases, the physical directory of the file can be seen to the right of the file name.

Global include

Global include


Visual studio also shows all subdirectories as folders while typing. In the following example I want to include some boost [http://www.boost.org] include files. I’ve defined the directory c:\boost_1_44_0 as an include path so that all other subdirectories will be recognized as include paths. The full path to the include file that I want is c:\boost_1_44_0\boost\filesystem\v3. In Visual Studio, I’ve started to type part of the full directory, out to “filesystem”. From there, we see that there are three subdirectories (detail, v2 and v3) as well as several .hpp files in the boost/filesystem/ directory.

Typing #include and a < shows all globel includes

External Dependencies
A new filter (looks like a folder in Solution Explorer) is a available called External Dependencies. This new folder gives you a bird’s eye view of all included files in the solution. This also includes all included files of your includes, which means that if you have many include files that include files, it may be difficult to use. Try adding <Windows.h> to a solution.

External Dependencies folder in Solution Explorer

External Dependencies folder in Solution Explorer

Extension Manager Surprise

Today, a nifty thing happened when I run Visual Studio 2010, a big dialog box opened up and announced a free download from Microsoft. At the top of the dialogue box I could see that it was the Extension Manager. And with a click of a mouse button, the Extension Manager started to download an extension to Visual Studio.

Extension Manager Updates screen

Extension Manager - Updates

Updates, Installed Extensions, and Online Gallery

Once the download stopped I was automatically taken to a web page on the Microsoft website that allowed me to download other extensions here: http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef. Here’s a short list: Emacs emulation, VSPackage Builder, PowerCommand For Visual Studio 2010.

Going back to the Extension Manager screen once the download was finished, I clicked on the Installed Extensions tab to see if the new extension would be available. Absolutely. Here’s what it looks like now:

Installed Extensions screen in the Extension Manager

Installed Extensions

Of interest are the Disable and Uninstall buttons which allow you to perform these two actions on the installed extensions.

It is also possible to click on the Online Gallery tab to view all extensions available on the Microsoft site as in the following image:

Extension Gallery - Online Gallery

Extension Gallery - Online Gallery

Where to Find the Extension Manager

To find the Extension Manager in Visual Studio, go the Tools menu the choose Extension Manager. The Extension Manager is not associated with a shortcut key by default.

Design a site like this with WordPress.com
Get started