Now Reading: Getting started with GitHub Copilot in Visual Studio or VS Code

Loading
svg

Getting started with GitHub Copilot in Visual Studio or VS Code

NewsJanuary 15, 2026Artifice Prime
svg13

The way software is developed has undergone multiple sea changes over the past few decades. From assembly language to cloud-native development, from monolithic architecture to microservices, from manual testing to CI/CD automation, we’ve seen the emergence of numerous software architectures, technologies, and tools to meet the ever-changing demands of enterprises and their developers.

Most recently, AI-powered tools have impacted software development dramatically. One such tool is GitHub Copilot, a powerful and accessible AI pair programmer that integrates seamlessly into Visual Studio and Visual Studio Code.

In this article, we’ll cover what GitHub Copilot is, why it matters, and how you can use it to generate and optimize code inside Visual Studio. We’ll also examine how GitHub Copilot can fix issues in your code and even help you test it.

What is GitHub Copilot and why do we need it?

Modern software development thrives on speed, accuracy, and innovation. Developers often spend a lot of time writing boilerplate code, integrating APIs, or debugging issues in the source code. Now with the emergence of AI and AI-powered tools and technologies, you can automate all of these time-consuming tasks to boost developer productivity.

GitHub Copilot is an AI-powered coding assistant that can generate code, optimize code, document code, fix issues, create tests, draft pull requests, and enable developers focus on creative, complex problem-solving tasks. GitHub Copilot, which supports models from OpenAI, Anthropic, Google, and others, is much more than a code autocompletion tool. It uses advanced AI models to understand natural-language comments and the context around your code, generate code snippets, automate repetitive tasks, reduce errors, and speed up your software development workflow.

While traditional autocompletion tools suggest code based on syntax, GitHub Copilot understands the purpose of your code, i.e., what the code is intended to accomplish, and generates entire code blocks or code snippets as needed. As a result, developers can be more productive and consistent, and write better code by adhering to the best practices and identifying and fixing issues and bugs early.

How does GitHub Copilot help software developers?

Here are a few ways GitHub Copilot can help you as a developer:

  • Boost productivity: GitHub Copilot can write boilerplate, repetitive, or verbose code in seconds. Hence, you can stay focused on building the architecture, writing business logic, and writing data access code rather than spending your time on mundane tasks.
  • Reduce cognitive load: GitHub Copilot can automate tasks, help write complex business logic, and reduce the need for context switching, reducing cognitive load and helping to prevent burnout.
  • Write efficient code: Using natural-language prompts, developers can generate readable, structured, modular, and consistent code. GitHub Copilot can also help with refactoring, bug fixing, and enforcing best practices.
  • Facilitate faster learning: Beginners and experienced developers alike can learn new libraries, APIs, or frameworks faster from the live examples GitHub Copilot generates.
  • Enhance testing and validation: GitHub Copilot can help you generate tests, explore edge cases, provide remedies, and fix issues in your code.

Install GitHub Copilot in Visual Studio

To install GitHub Copilot using the Visual Studio Installer, follow the steps outlined below.

  1. Launch the Visual Studio Installer.
  2. Choose the installation of Visual Studio you want to use.
  3. Click Modify to launch the next screen to modify workloads as shown in Figure 1.
  4. Select the workload you want to modify.
  5. Select GitHub Copilot and click Modify to start the installation.
Visual Studio Installer - GitHub Copilot

Figure 1

Foundry

This will install GitHub Copilot and integrate it inside your Visual Studio IDE. You can also install GitHub Copilot in Visual Studio Code, but we’ll use Visual Studio here. Whether you’re using Visual Studio or Visual Studio Code, getting started with GitHub Copilot is quick and easy.

Generate code using GitHub Copilot

You can use GitHub Copilot to generate new code giving it instructions in natural language. Just right-click in the code editor inside Visual Studio, click on “Ask Copilot”, and type an instruction. For example, you could ask Copilot to generate code to display all prime numbers between 1 and 100, as shown in Figure 2.

GitHub Copilot generate code

Figure 2

Foundry

Fix bugs in your code using GitHub Copilot

GitHub Copilot can also help fix bugs in your code. Let us understand this with a simple example. Refer to the following code.

string str = null;
for(int i=65; i<90; i++)
{
    str = str + (char)i;
}   
Console.WriteLine(str);
Console.ReadKey();

The idea behind the code above is to display all alphabetical characters from A to Z. However, there is an issue in the first statement. When you assign null to a string object and then attempt to add a string to it, the compiler will issue an error: “Cannot convert null literal to non-nullable reference or unconstrained type parameter.” This is because, beginning with C# 8, all reference types are non-nullable by default.

Figure 3 shows how GitHub Copilot fixes the code for you.

GitHub Copilot bug fix

Figure 3

Foundry

Optimize your code using GitHub Copilot

Consider the following piece of code that shows two classes, Customer and DataManager. While Customer is just another POCO class (plain old CLR object), DataManager creates an instance of the Customer class using a method called Create that accepts the customer details (i.e., values for all properties of the class) as parameters.

class Customer
{
    public Guid Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Address { get; set; }
    public string Email { get; set; }
}
class DataManager
{
    public Customer Create(Guid Id, string firstName, string lastName, string address, string email)
    {
        Customer customer = new Customer
        {
            Id = Guid.NewGuid(),
            FirstName = firstName,
            LastName = lastName,
            Address = address,
            Email = email
        };
        return customer;
    }
}

To optimize your code using GitHub Copilot, you can select the block of source code in the code editor, right-click and then click on “Ask Copilot”, and type “Optimize” in the input box, as shown in Figure 4.

GitHub Copilot optimize code

Figure 4

Foundry

When you click on the arrow button beside the input box to submit the “Optimize” prompt to Copilot, it will generate the optimized code as shown in Figure 5.

GitHub Copilot optimize code results

Figure 5

Foundry

Create unit tests using GitHub Copilot

Testing is key to reliable software, and GitHub Copilot makes software testing faster and easier. You can use GitHub Copilot to generate boilerplate test code for your functions or classes based on the logic it detects. Moreover, Copilot can provide you with suggestions for unit test cases across different scenarios, including edge cases. Copilot can also help create mocks or stubs for dependencies so that you can get to testing faster.

To generate unit tests with GitHub Copilot, right-click in the code editor inside Visual Studio and click “Ask Copilot”. In the input box, simply enter an instruction such as “Write unit tests for all methods of the DataManager class” as shown in Figure 6 below.

GitHub Copilot unit tests

Figure 6

Foundry

When you click on the arrow button in the input box, Copilot will create a new file in your project named DataManagerTests.cs and generate unit tests for the DataManager class as shown in Figure 7.

GitHub Copilot unit tests results

Figure 7

Foundry

Thus you can see how GitHub Copilot helps you reduce the time you spend writing boilerplate test code and helps you be more productive with test cases.

Key takeaways

By accelerating the coding process, fixing bugs, and writing tests, GitHub Copilot lets you focus on what really matters: building great software. Whether you’re building enterprise-scale distributed systems or rapid-prototyping new ideas, you should try GitHub Copilot and see how it can improve your software development workflow.

I’ll explore more GitHub Copilot capabilities, such as how Copilot can generate integration tests and improve test coverage, in future posts here.

Original Link:https://www.infoworld.com/article/4113948/getting-started-with-github-copilot-in-visual-studio-or-vs-code.html
Originally Posted: Thu, 15 Jan 2026 09:00:00 +0000

0 People voted this article. 0 Upvotes - 0 Downvotes.

Artifice Prime

Atifice Prime is an AI enthusiast with over 25 years of experience as a Linux Sys Admin. They have an interest in Artificial Intelligence, its use as a tool to further humankind, as well as its impact on society.

svg
svg

What do you think?

It is nice to know your opinion. Leave a comment.

Leave a reply

Loading
svg To Top
  • 1

    Getting started with GitHub Copilot in Visual Studio or VS Code

Quick Navigation