IntelliSense Improvements in Visual Studio 2019

Will

We’ve made many great improvements to C++ IntelliSense over the course of the Visual Studio 2019 release. We’ve collected a few of the highlights in case you are interested in upgrading to Visual Studio 2019 or just want to learn how to be more productive when writing C++ code. If you have followed our blog since the 2019 Previews, you may be familiar with some of these features already. We hope you find this collection helpful. If you want to try all these features out, please grab the latest release of Visual Studio 2019.

Many of these features are rooted in community suggestions. If you have any suggestions or run into issues with Visual Studio, please let us know on Developer Community. Your feedback really does help us deliver a great product!

C++ Standards

We strive to make Visual Studio the best IDE for working with the latest language standards. That involves a lot of work in our compilers and standard library but is not complete without the corresponding IntelliSense in the IDE to back these new features up while you are editing your code.

C++20

C++20 includes great new features such as modules, coroutines, concepts, ranges, the three-way operator, designated initializers and many more. All these features are supported in the IDE by the IntelliSense features you know and love.

For instance: coroutine support:

Co-routine Support in IntelliSense

Most of these features deserve a blog post on their own, so here they are if you want to learn more:

C++ Modernization

We want to make it as easy as possible to update your codebases to use the latest languages standards. One way to do this is with our code analysis, code tidying, and C++ linting tools. These work together and allow you to turn the dial in Visual Studio depending on how comprehensive you want to be in analyzing and updating your code. These features range from the very lightweight like our new C++ Linters that run inside the IntelliSense engine, to features like clang-tidy that bring in many more checks, and all the way up to the complete rulesets that MSVC’s Code Analysis provides.

In-Editor Code Analysis

The Microsoft Visual C++ Compiler has had extensive support for code analysis for some time. However, before VS 2019, you needed to compile your code before you could see any warnings or errors from this comprehensive analysis. In the latest version of Visual Studio, code analysis runs in the background for any files you are editing and results are shown directly in the IDE’s editor:

Image In editor Code Analysis

You can learn more about in-editor code analysis here.

IntelliSense Linter

We introduced the IntelliSense C++ linter as a complement to the more comprehensive code analysis that now runs in the background. The IntelliSense linter gives instantaneous results for the most critical issues, instantly, as you type. Currently, the linter is focused on common C++ typos, common bugs such arithmetic and operator mismatches, performance issues, and security issues such pointer arithmetic problems.

Image C Linter

This complements the more comprehensive code analysis from the compiler. While code analysis is much more flexible and powerful than the linter, it also takes longer to provide results because the translation unit must be compiled first. The linter is now enabled by default in Visual Studio. You can learn more about the IntelliSense Linter here.

C++ Concept IntelliSense

One of the great new features in C++20 is concepts. Visual Studio makes it easier than ever to create to create and use concepts in your code. In the first template in the code below we have defined a concept ‘is_cat’ that defines the properties of a cat. In the second template we use that concept to constrain the types that can be passed to it. This is fully supported by IntelliSense automatically and you can see that the Member List contains the methods defined by the concept above (‘pet’ and ‘meow’).

Image Concept IntelliSense

We didn’t need to provide any information to the IDE beyond the code and no types needed to be manually entered into the template bar (to the right of the second template). All the information instead comes from the concepts defined in the code.

Template IntelliSense

If you work with C++, you have no doubt encountered a great deal of templated code. Working with this in an IDE can be tricky because the IDE doesn’t know exactly how these templates are going to be instantiated. The new Template IntelliSense Bar in Visual Studio 2019 helps solve this problem. Using the Template Bar, you can tell the IDE how your template will be used and receive full IntelliSense based on those types. If you place the cursor in any template, you will see the new template bar:

Image Template IntelliSensepng

You may have noticed the “Instantiations” item in the type dropdown below. Visual Studio can now scan your entire codebase to automatically provide suggestions on how the template may be used. You can learn more about the Template Bar here.

Perfect Forwarding IntelliSense (make_unique, make_shared, emplace, emplace_back)

One piece of community feedback that we have received has been to improve the IntelliSense for perfect forwarding templates in C++. We’ve taken the first steps towards that by improving the way a few perfect forwarding templates in the STL are handled. In particular, make_unique, make_shared, emplace, and emplace_back.

Here is how this looked before:

Image Perfect Forwarding Before

Notice how the parameter help doesn’t list the actual parameters of your type. In the latest version of Visual Studio, it is much more convenient:

Image Perfect Forwarding After

We don’t want to stop with just these four STL functions though. We are investigating ways to support your own perfect forwarding templates here as well. As always, we would love to hear your feedback about this. If you are interested in this feel free to open a suggestion on Developer Community.

C++ Productivity

In addition to language conformance and modernization tools, we also want Visual Studio to be the most productive IDE on the market to get work done. With that in mind, we have added a number of productivity focused IntelliSense features in 2019.

IntelliCode

IntelliCode uses machine learning to provide better code-completion recommendations. We added IntelliCode support for C++ in Visual Studio 2019.  By default, IntelliCode will give you recommendations on popular libraries such as STL.

Image Member List with with and without IntelliCode

We took this a step further in Visual Studio 2019 16.5 where we added the ability to train IntelliCode on your own codebase. This enables you to get smarter completion recommendations on your team’s own types. To keep your Team Completion model up-to-date, you can automate the training process using GitHub Actions or Azure Pipelines.

Image Custom IntelliCode Animation

Intelligent Member List Filtering

The Member List now takes more of your code’s context into account when listing available members. For instance, if you invoke the member list on a const variable, all non-const variables will no longer be shown in the list. Partial matches are also now highlighted in bold in the Member List as well.

Image Member List Filtering

You can learn more about Member List filtering here.

Doxygen Support

Another feature we received feedback from the community about was that our customers wanted Doxygen support in the IDE in addition to XML doc comments. In Visual Studio 2019, Doxygen is now fully supported in C++ and will provide information in the Quick Info and Parameter Help UIs:

Image Doxygen Support

Visual Studio does not default to Doxygen style comments, but they can be enabled in “Tools > Options > Text Editor > C/C++ > Code Style > General”. Additionally, you can add your preferred type of doc comment to your project’s .editorconfig file. You can learn more about Doxygen support here.

IntelliSense Colorization and Quick Info Improvements

To help you be as productive as possible, we’ve made several enhancements to the Quick Info, Parameter Help, and Member List UIs. The first thing you might notice is that these UIs are now fully colorized to match the editor:

Image Quick Info and Member List Colorizaiotn

Quick Info also now allows you to easily search for errors or function and type names online. You can now just hover over any red squiggle in the editor instead of searching through the error list:

Image Search From Quick Info

You can learn more about the enhancements to Quick Info here.

Snippet Commit Options

We’ve received feedback to make the commit options for snippets and the Member List more flexible. The defaults remain the same, but there are new options to choose between Enter, Space, and Tab now in “Tools Options > Text Editor > C/C++ > Advanced > IntelliSense”:

Image Snippet Commit Options

Platform Support and Extensibility

We have introduced new flexibility and extensibility in our IntelliSense engines to support a wide variety of platforms, such as Windows, Linux, and consoles. This includes the ability to configure the IntelliSense engine with a CMake toolchain file. These toolchains can be checked in to your code and each configuration can have a unique toolchain bringing an unprecedented amount of flexibility.

Additionally, we have made several updates to the way IntelliSense is handled for remote machines. This improves the accuracy of remote IntelliSense by automatically downloading system and library headers from the remote machine (or WSL) and using them to provide full fidelity IntelliSense with the actual headers on the machine you are targeting.

Send Us Feedback

Please grab a copy of the latest update to Visual Studio and try it out. We would love to hear your feedback about Visual Studio. Please submit any suggestions to Developer Community.

Posted in C++

14 comments

Comments are closed. Login to edit/delete your existing comments

  • ryutorion

    Option to enable Doxygen is not “Tools > Options > Text Editor > C/C++ > General”, but “Tools > Options > Text Editor > C/C++ > Code Style > General”, isn’t it?

  • Rafq

    Each feature is better than the other one. And a linter on top of that? That’s great!

    Will these IntelliSense features be supported for VSCode as well?

    • Will BuikMicrosoft employee

      Glad to hear it. Our goal is to eventually bring many of these features into VS Code but at the moment I can’t comment on an exact timeframe.

  • Mike Diack

    Hi

    Please take a look at:

    https://developercommunity.visualstudio.com/t/Very-frequent-crashes-of-Visual-C-Pack/1356188?port=1032&fsid=80bf2833-da60-4304-b9b7-1dcef1bf8f91&entry=myfeedback&ref=native&refTime=1615469393337&refUserId=e9544aaf-08f5-4f58-997a-3c2506a19dd7

    I have found (and Microsoft have now reproduced) a bug in VS 2019 Update 10 Preview 1 (worked fine in VS 2019 Update 9 Preview 5), that Intellisense constantly crashes on Windows 7 and 8.1 systems but not on Windows 10(!).

    Please fix this – we’re not all developing on Windows 10 development PCs.

    The bug on Win 8.1 (where I found it) is really severe.
    It crashes constantly and reproducibly over and over and over again (as soon as background intellisense kicks in), and the only workaround is to disable it completely. It’s a regression in VS 2019 Update 10 Preview 1 vs Update 9 Preview 5. Please fix it. VS IDE without Intellisense almost loses the point of VS!

  • David Hunter

    Hi, I was wondering if I should expect intellisense to work if I am using the experimental STL modules? Currently I see a lot of red squigglies when I use them but am wondering if that is because there is some option I have not set.
    Anyway I find intellisense generally to be awesome!

    • Will BuikMicrosoft employee

      This is a known issue. Some modules (such as the STL modules as you found) still are not fully compatible with IntelliSense in the IDE. We expect that this should be fixed in the next update to Visual Studio 2019.

  • James Wil

    modules doesn’t work if i reference a c++20 module project, i can go to definitions, but everything has red lines https://i.imgur.com/aNE9MPo.png

    other than that it is a solid release, thanks so much for your hard work, modernizing C++ and its tooling is a massive task, you guys are very talented! thanks!

    • Geoffrey Hoffmann

      I have the same thing. Modules are unusable, in my opinion. I notice there has been no answer from MS…

      • William Alexaindre

        In a project with two files intellisense work with modules, with bigger projects cl compiles but intellisense say errors E0020, E3275 :/

  • Michael

    re: C++ Concept IntelliSense / Perfect Forwarding IntelliSense: How feasible is it to use concepts to drive IntelliSense at the call site, not just the function implementation? e.g. If there’s a constraint using constructible_from on some of the template arguments, then that seems like a rather strong hint to display constructor argument hints. constructible_from is technically over constrained for a completely general purpose solution to this because it doesn’t permit friendship, and requires destructibility. (suggested here: https://developercommunity.visualstudio.com/t/Intellisense-C20-concept-awareness:-co/1356573)
    And then further craziness: presenting pseudo-function signatures in the tooltip hints if confronted with a template parameter that is constrained with invocable, predicate, indirectly_unary_invocable, indirect_unary_predicate, etc.
    And then even more craziness: propagating the constraints down to a generic lambda, so that with this example:

        std::vector v;
        std::ranges::find_if(v, [](const auto& s) { return s.empty(); });

    typing “s.” would show the available const members of std::string. (And when “in” the second parameter for find_if, something akin to “bool (std::string&)” would show up where “_Pr Pred” is today.

    Those three have basically been my “dream” wishlist items for concepts and IntelliSense for as long as I can remember. Divining what std::constructible_from “means” seems “easy” since it’s entirely defined in terms of compiler intrinsics which is why I already made a suggestion for it, but reversing std::invocable seems challenging.

  • John Smith

    I’m missing the helpful IntelliSense’s popup that assisting me when I was on C#.
    C++ doesn’t provide these assistance =
    – Hovering on function or class name from STL rarely show any English description, especially on MSVC.
    – The selection list on auto-complete also rarely show any English description, especially for MSVC STL.
    – When trying to filling the argument for function or argument, only the signature is shown, no helpful English description explaining the purpose for each argument.

    So far the popup on C++ will display “Search Online”. Would be great if the C++ can provide a helpful popup similar with C# or Java.
    I see that you have invested a lot of effort on putting the STL documentation on MSDN, would be great if that could be incorporated into IntelliSense code-assisting feature.