- GitHub Copilot provides real-time code suggestions & auto-completes them as you type, speeding up the coding process and increasing productivity.
- To know how to use it on Visual Studio, keep reading!
If you are looking for a way to speed up your coding process in a Visual Studio environment, GitHub Copilot, an artificial intelligent pair programmer, can help!
In this guide, we will explain the step-by-step instructions to install the extension and how to utilize the tool’s artificial intelligence in the Integrated Development Environment.
Is GitHub Copilot free in Visual Studio?
How we test, review and rate?
We have worked for the past 6 months on building a new review system on how we produce content. Using it, we have subsequently redone most of our articles to provide actual hands-on expertise on the guides we made.
For more details you can read how we test, review, and rate at WindowsReport.
If you are a student, teacher, or maintainer of a popular open-source code project, then you can install GitHub Copilot for free. However, if you don’t fall into these categories, you can get a one-time 30-day free trial of the tool.
How do I use GitHub Copilot with Visual Studio?
Before proceeding with any steps to get GitHub Copilot and use it on Visual Studio, go through the following preliminary checks:
- Updated version of Visual Studio 2022 or 2019.
- A working GitHub account.
- Sign up for a GitHub Copilot technical preview subscription.
- A stable internet connection
1. Download the GitHub Copilot extension
- Press the Windows key, type visual studio and click Open.
- Go to the Extensions tab and select Manage Extensions.
- Locate the search bar from the top right corner, type github copilot, select the appropriate result from the left pane, and click Download.
- Once downloaded, close Visual Studio, and you will be prompted to install the GitHub Copilot extension; click Modify.
- Follow the on-screen instructions to complete the process and relaunch the Visual Studio 2022 app.
2. Add the GitHub account to your Visual Studio
During the installation process, you might be prompted to sign in to a Microsoft account linked with your GitHub if you haven’t already. If not, follow these steps to add your GitHub account to Visual Studio:
- On the Visual Studio app, click the Profile icon, select Add another account, then choose GitHub account.
- You will be redirected to the GitHub sign-in page on your browser; enter the credentials and 2FA code if needed to sign in. Once done, close the browser window and return to the app.
3. Setting up GitHub Copilot for use
- On the Visual Studio 2022, click File, then New> Project.
- On the Create a new project page, select any of the options available and click Next.
- Name the project and click Next.
- Click Create.
- You will get the GitHub Copilot icon on the bottom left corner of the Visual Studio 2022 app. Click it to get options like Enable Globally, Enable for CSharp, and more. Click on any of them to activate and customize it as per your preferences.
- Now start typing the code, and you will get suggestions or corrections in grey color. You can click them or press the Tab button to accept. You can also ask questions or ask the tool to write code for a certain thing. For example, to get the rainbow colors type this command and press Enter:
//Generate an array of all the colors from the rainbow
- The tool will use artificial intelligence and produce a suggestion in grey color; if you want it to include it, press the Tab button on your keyboard.
Exploring Features of GitHub Copilot in Visual Studio
- Natural language support for programming languages – GitHub Copilot’s artificial intelligence understands & processes natural language to provide code suggestions, making it easier to translate ideas into actual code efficiently.
- Autocomplete-style suggestions – Offers suggestions for entire functions, methods, and even code snippets, reducing manual coding, thereby saving time and increasing productivity.
- Personalized suggestions based on context – Provides suggestions on the context of a function, variable name, and even keyboard shortcut, helping you complete the code faster.
- Ability to analyze billions of lines of code at once – GitHub Copilot has been trained on vast amounts of codebases, therefore, it can analyze code to provide relevant suggestions.
- Accessible from the left-hand side panel – You can click the GitHub Copilot’s icon and select Open Copilot to get it on the left side, ensuring an integrated and seamless experience on Visual Studio.
- Neural network – The tool uses a neural network, a variant of the Generative Pre-trained Transformer (GPT) architecture, to generate intelligent and accurate code completion suggestions.
- Add comments or structured blocks of code – It suggests relevant code and also helps add comments and structured blocks faster, which improves code readability and manageability.
- Boilerplate code generation – When you start a new function, method, or class, GitHub Copilot can generate the initial boilerplate code, which saves you time and helps you focus on writing the core logic of a program.
The seamless integration of GitHub Copilot within Visual Studio can help you perform repetitive tasks faster and more efficiently. You can add the GitHub Copilot for Business using the same steps. To know more, read this guide.
Using the tool not only accelerates the development of the code but also nurtures learning by offering educational insights. You can also add its extension to Visual Studio Code, Azure Data Studio, JetBrains suite of IDEs, Vim, and Neovim.
Another AI-powered virtual assistant by Microsoft is Microsoft 365 Copilot; you can add it to Outlook, Word, Excel, and other 365 apps on your Windows, Mac, or mobile OS to get suggestions for various repetitive tasks.
Download GitHub Copilot, use it, and tell us your experience and what you think about the tool in the comments section below.