Type less, code more with IntelliCode completions

Mark

In Visual Studio 2022 Preview 1 you can automatically complete code, up to a whole line at a time!

Check out the video to see what it can do; it shows writing real code from a controller of the ASP.NET eShopOnWeb reference application.

You can try this for yourself right now, on your own C# code!

Rich context gives great completions

IntelliCode now predicts the next chunk of code based on your current context, and presents it as an inline suggestion to the right of your cursor. If you like it, just hit tab-tab to accept it; otherwise simply keep on typing to adjust the completion further.

To achieve this, IntelliCode uses a large scale transformer model, trained on around half a million public open-source repos from GitHub. It combines this with a rich knowledge of your coding context, taking cues from it including:

  • Variable names and positions
  • The sort of code you’re writing (e.g. the libraries you’re using)
  • Functions in nearby code
  • The IntelliSense list – changing your selection in that list steers the model with extra context, so you can easily explore different completions to get to just the code you need

It runs right on your local machine while you’re editing, and covers many programming languages too. For our initial preview release we’re supporting C#, but watch for more languages coming soon!

Let us know what you think!

IntelliCode has benefitted greatly from all the rich feedback we’ve received from you – thank you! We hope you’ll help us continue to improve by giving the newly enhanced completions a try and letting us know what you think.

Please report any issues you see via Developer Community and file feature requests if you have them.

6 comments

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

  • Paulo Pinto

    Looking forward to see this on IDL as well, if by Visual 2022 there is still no way around to WinUI with C++ than putting up with C++/WinRT bare bones tooling.

  • David Villarreal

    is this using the new gpt3 model. do you think that now that microsoft has a private license to gpt3 it will add something like this to vscode, or is the model more optimized for code, because gpt3 can be “slow” (not really slow but not it can have a noticeable lag sometimes even though im sure most people wont mind

    • Mark Wilson-ThomasMicrosoft employee

      This does not use GPT3, but rather a large scale transformer model specialized for code usage (GPT-C), and able to run with good performance on your local machine via the ONNX runtime. We’ll be publishing a blog with more details in the near future. The model is multilingual – watch this space for coverage of other languages and Visual Studio Code

  • Robert Rioja

    Is there a way to change the keyboard shortcut to insert? I regularly need to insert an actual tab and end up getting a line of code I wasn’t ready for.

    • Mark Wilson-ThomasMicrosoft employee

      Hello Robert, and thanks for the feedback!

      Yes, you can change the commit character to right-arrow, using Tools-Options-IntelliCode – once in that options page, look for the “Completions for whole lines of code” section and find “Apply completions for whole lines on right arrow”. Set that to “Enabled” and restart Visual Studio, and you should find that right arrow commit is enabled (the cues on screen will change accordingly). This will mean you can commit the whole line of suggested code regardless of whether the IntelliSense dropdown is showing on screen or not, and you can use the tab key even when a prediction is showing. Do let me know how you get on and what you think of the new feature once you’ve made this change.

      I’d be interested to understand more about the cases you need to insert a tab character right after committing the IntelliSense window’s contents – can you drop me a line on mwthomas@microsoft.com and tell me more if you’re willing?

      Regards
      Mark

  • Ryan Pavlik

    I’m concerned that this is effectively making a lot of “derivative works” of open-source code without proper licensing.

    How will this feature ensure that users’ code/products provide proper attribution to the projects used to train this statistical model? (Without being able to trace contributions of each project, it seems reasonable, if difficult, that all projects need to be attributed.) What repositories were used, to be sure that the model and suggestions are not derived from reciprocal-licensed code, and so that users can provide appropriate attribution?