In Visual Studio 2022 Preview 1 with the power of advanced IntelliCode, you can automatically complete a line of code at a time. IntelliCode is One of the new features of Visual Studio 2022 that can dramatically improve your coding productivity. It is an AI and ML-enabled coding engine that understands your coding context as you type your code, and predicts the complete line as you move. The IntelliCode model in Visual Studio 2022 trained over half a million open-source Github repos. It understands the library you are using, the object you are instantiating, variable names that you are referring and the overall context of your code and then predicts the next set of code which you can just select by pressing tab-tab.
Visual Studio 2022 IntelliCode Features
You can start experience this with Visual Studio 2022 Preview 1. Download the Preview Version and Open the code editor. Here, as soon as you start typing, it will start providing you the contextual suggestion and option to accept.
Consider one simple example, as shown in the below image. As soon as you type StringBuilder, it started predicting the complete line that creates an instance of StringBuilder. Once you press TAB + TAB it will accept and move to the next line. You can continue typing if you don’t want to accept it. Now, as soon as you accept the changes, by pressing the Tab Twice, it will complete the statement.
Now, once you come to the next line, Visual Studio automatically pick up the stringBuilder variable from the context and will predirct for your acceptance.
Related Tip : Visual Studio 2022 is a 64-bit application.
Once you press Tab and Accept that, as generally we start adding the text with in StringBuilder using StringBuilder.Append() method, you have the same prediction.
One you use StringBuilder.Append() and add some text in the context, in the next state if you want to write it out, just type Console, the prediction engine will automatically recommend the complete line.
This IntelliCode connect with Visual Studio backend services to keep updated with model and prediction.