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.
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.
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.
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.
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.
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.
It allows you to search your entire solution all the way to the members of individual classes.
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.
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.
The second category of C++ features helps you with editing code faster.
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.
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.
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
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 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.
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!
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]
Awesome stuff. Would love to have refactoring functionality such as rename.
Very nice. but please, make sure the GUI keeps being responsible and fast.
At last, we'll see something new in vs c++!
Thanks, keep going, forget about VB, and keep in mind that c# is not the only language!
Greaaaaaaaaaaat! While syntax colouring as here presented is, IMHO, not requiered, it's still a nice feature to have, and certainly shows that MS is taking more seriously the C++ devs. However, that enhanced solution explorer... wow, I can't just thank you enough for that. For years I've been using solution explorer / class view. Have them both in one place would indeed increase my productivity, by not having to switch between views. That was just awesome. Thanks!
With the extremely important caveat that these new features don't adversely affect performance (i.e., VS 20-next is not any slower than VS 2010), this is AWESOME!!
You guys have taken the best features of Visual Assist X, Highlighterr, and the VB.NET/C# IDEs, and integrated them into the C++ IDE. Nice work, and kudos for listening to user demands (i.e., us)!
It also caught my eye that in a couple of places, you specifically mentioned including the ability to turn these features off. That's great, too. There's something to be said for minimizing the number of choices in consumer-level software, but in a package like Visual Studio, targeted to expert users with a myriad of preferences and possible use cases, it's absolutely imperative that customization be available. Moving the IDE forward is always great news, but being able to turn off what we don't like is even better.
Thanks again for the GREAT features (and looking forward to built-in refactoring support, hint hint).
Don't know if anyone's still reading this, but I've been playing with the aggressive auto-complete feature in the Developer Preview. There's an annoying difference between it and the regular ctrl+space list: with the new feature, you always have to press enter or tab to complete the word. However, with the ctrl+space list, typing space (or punctuation marks like . or -> for member selection) does the job if you've typed a prefix of a recognised identifier.
I'd like to see that work here too. It might annoy some people, but there could be an option to switch it off in the Text Editor C++ settings. If I start typing an object variable name, I always type . etc. once I've seen the highlight, because I've been trained that way from the ctrl+space list. Now in VS11 it doesn't do the completion, and I have to waste time going back and editing the word again, remembering to use ctrl+space or some other key to actually complete it.
Ordinarily I hate this style of thing (see auto-complete in iOS!) but if it was restricted to strict prefixes it might work well, just the same as it does in the ctrl+space list.
Any chance this will get fixed for the final release of VS11?
"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"
Why don't you make the options dialog re-sizable? The display options list box is way too small considering
the amount of items it has. Also you should add a filter to help find items to colorize. It extremely tedious going
through the list trying to manually find items.
"Beauty is in the eye of the beholder". It is nice that your are providing visual enhancement; however, and this is important, with UI you MUST allow/provide the ability to enable/disable any so-called enhancement. Everybody is different and visual effects are subjective. PLEASE provide a way to turrn OFF those annoying italics!