First Look at the New C++ IDE Productivity Features in Visual Studio 11

First Look at the New C++ IDE Productivity Features in Visual Studio 11

  • Comments 53

Sumit Kumar

Hi! I am Sumit Kumar, a Program Manager on the Visual C++ team.

Today I will talk to you about some of the exciting new IDE functionality in the next version of Visual Studio that will make you, the C++ developer, more productive with your daily code focused tasks. In this blog post you will get a preview of the new features that help with code understanding and editing. There will be more blog posts talking about other cool new features.



Code Understanding enhancements

Semantic Colorization

Semantic Colorization helps you quickly scan the code and infer more semantic meaning through enhanced visual feedback in the editor. In addition to the keywords, strings and comments, now other tokens like types, enumerations and macros are colorized; the parameters are in italics and so on. The screenshot below shows an example. Notice how the macros, types, function parameters etc. pop out and make understanding code so much easier.

Semantic colorization

While there are only a few tokens that are colorized differently by default, around twenty different semantic tokens are exposed to the users as shown in the screenshot below.

Fonts and colors

You can customize your IDE to colorize these tokens differently. For example, you could choose to colorize local and global variables differently which could be a handy source understanding aid when the variables are identically named but defined in different scopes.


Reference Highlighting

Another great productivity feature that aids you in understanding code is Reference Highlighting. When you place your text cursor on a symbol, all the instances of that symbol in the file get highlighted. Only the true references are highlighted – for example, two symbols with same names in different scopes (say local vs. global) will not be highlighted at the same time. You can use Ctrl+Shift+Up and Ctrl+Shift+Down keys to move between the highlighted references. This means that you no longer have to invoke Find All References if you are simply looking for symbols within a file. The screenshot below shows how all the instances of the variable cxExtentMax inside the function body are highlighted when the cursor is placed on the one referenced in the call to max(). But the variable with same name defined outside the function scope is not highlighted.

Reference highlighting


New Solution Explorer

There are a number of tool windows needed for common everyday tasks – for example, Navigate To is used for searching symbols and files, Class View and Object Browser are used for inspecting the members of an object, Find All References is used for, well, finding references, Call Hierarchy is used for finding the calls to and from a function etc. Imagine being able to do all of these operations from a single tool window without having to switch context or sacrifice additional precious screen real-estate. The new Solution Explorer combines most of the functionality of these tool windows into one place, itself! Of course, the other tool windows will still be available in Visual Studio, but the goal of the new Solution Explorer is to significantly reduce the need to invoke them for the most common scenarios. A detailed description of all of the new functionality provided by the versatile new Solution Explorer is a separate blog topic in itself, but here is a sampling:

You can expand your files to see the fields, functions and types contained in the files and the members contained in the types.

New Solution Explorer

It allows you to search your entire solution all the way to the members of individual classes.

New Solution Explorer

You can navigate back and forward between different views of the Solution Explorer and can create multiple instances of Solution Explorer rooted at different nodes if needed. You can also scope the view to just a specific project or file or type.

New Solution Explorer

The view in editor automatically syncs with the view in Solution Explorer. Clicking on a symbol node in the Solution Explorer takes you to the definition of that symbol in the editor. You can also see the relationship between functions such as Calls to, Calls from, References, and Inheritance for functions and types from within the Solution Explorer.

New Solution Explorer

New Solution Explorer



Code Editing enhancements

The second category of C++ features helps you with editing code faster.

Automatic Display of IntelliSense Member List

In Visual Studio 2010 and previous releases, the IntelliSense member list dropdown had to be explicitly invoked either by typing Ctrl+Space or Ctrl+J or entering a scope resolution operator (::) or element selection operator (. or ->). In the next version, Visual Studio will automatically shows the member list drop down as you type without the need to explicitly invoke it.

Automatic Display of IntelliSense Member List

The automatic display of member list is smart – it does not aggressively display the member list when it does not make sense, for example when typing a declaration, there is no aggressive display of member list.

Automatic Display of IntelliSense Member List


Member List Filtering

Not only is the member list displayed automatically, it is also filtered as you type to shrink and show only the relevant members. So you can get a filtered result like the screenshot below just by typing two characters

Member List Filtering     Member List Filtering

Notice that pb is not a prefix or even a substring of the members in the list. The filtering uses a fuzzy logic to find the relevant members quickly. But if you do not like the fuzzy filtering, you can change it to prefix based, or prefix plus camel casing based or turn off the filtering completely.


Code Snippets

Code Snippets help you quickly type the boilerplate code with just a couple of keystrokes. Here’s how it works for a switch statement: as you start typing, the IntelliSense member list shows you the relevant code snippet that can be selected by pressing tab.

Code Snippets

Code Snippets

Then modify the expression in the switch statement or just press Enter and the entire skeleton of the switch statement is added for you; you only need to fill in the logic!

Code Snippets

In addition to the switch statement, there are other snippets for basic code constructs available to you – like if-else, for loop, etc. Each of the snippets saves you from unnecessary typing and lets you focus more on your logic, adding up to significant productivity gains over time!

Additionally, the code snippets feature is extensible so you can also create your own snippets, which is as simple as creating a simple XML file and copying it at a certain location. You can also invoke the code snippets from the context menu in the editor and can either insert a snippet or can surround a selection of code with a code snippet (for example with a #ifdef statement).




Many of these code understanding and editing features were requested by you, and are squarely intended to make you more productive with C++ development. Your continued feedback will help us make these features better before they ship. Please note that the descriptions and screenshots are from our early internal builds. These features are still under development and could potentially change or not even be included in our final product. In addition to these new features, we have done a lot of work on the IDE but I will save those for future blog posts.


[Keep learning about new features for C++ developers in Visual Studio 11]

  • @Brian Kramer: I agree managed vs native is not the whole problem, but I think it is part of the problem. This is more complex than microbenchmarks between C# and C++. When you set to use, say, WPF, you buy into a certain design. Some things become simple, some more complex, some naturally fast and some naturally slow. I wouldn't argue that WPF is inherently bad for something like a text editor, but we can all see that the text editor in VS2010 is very slow, and I think a significant part of that might indeed have to deal with the default design decisions that came from WPF. I am not saying this can't be amended, but that's far from the first time we've seen managed code perform badly, including both Microsoft's products and our own products, and, well, after some time you can't help but notice the pattern: making managed code perform as fast as native code is hard. So, why bother with managed code at all...

  • Reference Highlighting is down when there're Chinese(or other foreign characters I don't know) comments above the code. VS2010 Ulitmate Enu installed.

  • I have been extending Highlighterr to support as much highlighting as possible and in the process learned a lot about why the Intellisense feature is so slow. The database basically only contains definitions and not local variables and has several limitations:

    * Only the root code element is saved, so if you for example have a macro that generates a member variable, that macro is saved, but not the resulting member variable

    * If you have a macro that expands to for example __forceinline for portability reasons or define pure to =0, that breaks other modifiers such a static and the database does not record the function as pure

    * Local variables are not stored in the database

    * It's sometimes not possible to get the full name of a type with respect to namespaces (using directives)

    With this in mind it's not mindboggling to see why intellisense is so slow, it has to parse a lot of things on demand. It's not unusual for me to wait 20 to 30 seconds for a goto definition.

    Highlighterr uses the intellisense database directly and from my testing that is because using the code model interfaces is incredibly slow because of the dynamic parsing going on.

    I'm not sure why the design decision was made not to actually store all code information in the intellisense database, but the only reason I can think of is that it's limited to 4 GB because of the underlying database technology.

    I can only assume that the vNext will have these issues resolved to be able to support local variable reference highlighting.

    The Highlighterr code caches all definitions into a global cache which makes name collisions inevitable so built in (hopefully extensible) highlighting support is very welcome.

    For reference see the list: for the highlighting I managed to support working directly with the intellisense database. To make it work reasonably I had to use code naming standard rules to prioritize name collisions.

    In vNext I hope to be able to add highlighting options for local variables. It would also be nice to have hierarchical options for defining syntax coloring so you could define a group (for example C++ Keyword) and then drill down to change only one sub-type (private/protected/public).

    Maybe the VS team could get some ideas from the list below, especially private/protected/public highlighting is nice to have.

    Looking forward to the first vNext CTP. Please make it installable alongside Visual Studio 2010 in the first version if you want real testing early.

  • This great. I can seen some of this in Resharper, IntelliJ IDEA, and Whole Tomato.

    Keep it coming!

  • Thanks a lot to everyone for all the comments.

    About performance – we appreciate the passionate feedback. While I cannot promise that we will fix all of your complaints in the next version of Visual Studio, we are hard at work addressing a number of these and will be able to share more details are we get closer to the release of next version.

    Thanks to AndrewDover for sharing the link for the blog post on PerfWatson tool and how we are using it to prioritize the performance fixes. If you are not aware of the PerfWatson extension, I request you to download it from - [url] [/url]   and help us by sending automatic reports on performance issues.

    Additionally, if you would like to share the specifics of the issues and relevant details like project LOC, machine configuration etc. please contact me at sumit dot kumar at microsoft dot com. Any additional details we can get would help us investigate further and fix more issues. Thanks in advance for your help.

  • @ Simon Buchan

    Yes semantic colorization and other features described here work well on templates and macros etc. And you are correct about the Solution Navigator extension - it did not have C++ support.

  • @ Knowing me knowing you, a-ha

    Yes, there will be an option to turn off automatic display of member list (and other features) under Tools > Options > Text Editor > C/C++ > Advanced.

  • @ AlefSin

    Unfortunately the next version will not have Rename refactoring.

  • @ Jschroedl

    Yes, all of these features will work on C++/CLI.

  • @Sumit thanks for your answer, just to clarify, I will be able to disable "agressive" intellisense but I will still be able to have it "on demand" by pressing "ctrl + j" is that so?

  • That is correct, the option to disable aggresive will just disable that specific feature, you will still be able to do invoke it through the usual shortcuts.

  • Finally I won't have to pay for Visual Assist X ...

  • Like many other comments, I would just ask for better performance, especially for large projects. VS2010 is much much slower than VS2005/VS2008. Would you mind throwing away the WPF UI of VS2010, please ? This interop was certainly very difficult to achieve, but...

    Oh, the features you are showing here are nice... (if vsNext is not too slow)

  • Visual C++ could feature something similar to this

    where each function parameter/variable is colored differently

  • It's nothing short of wonderful to see this much investment in native tooling. Can't wait to get my paws on early bits and give it a whirl.

Page 3 of 4 (53 items) 1234