VS Code GitHub Copilot
GitHub Copilot is an AI coding assistant jointly developed by GitHub and OpenAI; it can automatically complete code based on context, generate functions, optimize logic, and even write entire code modules, helping developers code more efficiently.
GitHub Copilot is integrated into many IDEs such as VS Code, Visual Studio, and JetBrains, making you feel as if an experienced partner is always assisting you while you write code.

Core Features
Code auto-completion
GitHub Copilot can provide real-time code suggestions based on your code context and comments. It can:
- Complete entire lines of code
- Generate complete functions
- Generate code from descriptive comments
Code explanation
Copilot can help you understand unfamiliar code:
- Explain the functionality of complex code snippets
- Provide code optimization suggestions
- Identify potential problems
Multi-Language Support
Supports almost all mainstream programming languages, including:
- JavaScript/TypeScript
- Python
- Java
- C++
- Go
- Ruby, etc.
Installation and setup
Installation Steps
Prerequisites
-
VS Code is properly installed; the recommended version is
1.116+or above; this version has Copilot built in natively, so no manual plugin installation is needed. -
A GitHub account, and the GitHub Copilot subscription must be enabled (Individual, Team, or Enterprise plans are all acceptable).
Install the extension (older VS Code 1.115 and earlier versions)
-
Open VS Code and go to the Extensions Marketplace.
-
Search
GitHub Copilot。 -
Click
安装(Install)installation.
After installation, click the small icon in the upper-right corner to bring up the Copilot chat window:

You can also click the icon in the lower-right corner:

Log in to your GitHub account
-
After installation, VS Code will prompt you to log in with your GitHub account.
-
Click
Sign in to GitHub, the browser will redirect to the GitHub authorization page, and after authorization it automatically returns to VS Code.
Enable GitHub Copilot
-
Press
Ctrl + Shift + P, then typeCopilot: Enable。 -
in VS Code; after confirming enablement, you can start using it.
After installation, open VS Code's settings and search for Copilot; here we can adjust in VS Code settings:
- Suggestion trigger mode (automatic or manual)
- Suggestion display position
- Language preference settings

Usage tips
Intelligent completion
When you start typing code, GitHub Copilot automatically gives suggestions, for example:
function fetchData(url) {
// Copilot will automatically provide an implementation based on the fetch API
}

We can press the Tab key to accept a suggestion.
-
If there are multiple suggestions, you can press Ctrl + ] or Ctrl + [ to switch.
-
If you don't want to use a suggestion, press Esc to dismiss.
Generating code from comments
Simply write a comment, and Copilot will help you implement it:
# Implement a quicksort algorithm

Example
Implement a quicksort algorithm
def
quick_sort
(
arr
)
:
if
len
(
arr
)
<=
1
:
return
arr
pivot
=
arr
[
len
(
arr
)
//
2
]
left
=
[
x
for
x
in
arr
if
x
<
pivot
]
middle
=
[
x
for
x
in
arr
if
x
==
pivot
]
right
=
[
x
for
x
in
arr
if
x
pivot
]
return
quick_sort
(
left
)
(
right
)You can even write a comment directly to have Copilot generate tests for you:
// 为 quicksort 函数生成单元测试

Also, we can right-click in the editor, select Copilot, and bring up the desired feature:

Keyboard shortcut descriptions:
| Keyboard shortcut | Description |
|---|---|
Tab |
Accept suggestion |
Esc |
Ignore suggestion |
Ctrl + ] |
View next suggestion |
Ctrl + [ |
View previous suggestion |
Ctrl + Enter |
Open Copilot panel |
Ctrl + Shift + P |
Enable/disable Copilot |
Using the chat feature in VS Code
In Visual Studio Code, the chat feature lets you ask questions about the codebase in natural language or make multi-file edits in your project. The chat feature can run in different modes according to your needs, from asking questions and making multi-file edits to launching agentic coding workflows — it can meet all your needs.
You can use VS Code's chat feature in the following scenarios:
- Understand code: For example, "Explain how this authentication middleware works?"
- Debugging problems: For example, "Why do I get a null reference in this loop?"
- Getting code suggestions: For example, "Show how to implement a binary search tree in Python?"
- Optimizing performance: For example, "Help me improve the efficiency of this database query?"
- Learning best practices: For example, "What is the recommended way to handle errors in async functions?"
- Getting VS Code tips: For example, "How do I customize keyboard shortcuts?"
Tip: If you do not yet have a Copilot subscription, you can use Copilot for free by signing up for the Copilot Free plan, which has a monthly limit on completions and chat interactions.
Chat modes
Based on your specific needs, you can choose different chat modes:
| Mode | Description | Scenario |
|---|---|---|
| Ask | Ask questions about the codebase or technical concepts. | Open in Stable or Preview. Understand how code snippets work, brainstorm software design ideas, or explore new technologies. |
| Edit (Edit) | Perform multi-file edits in the codebase. | Open in Stable or Preview. Apply code edits directly in the project to implement new features, fix bugs, or refactor code. |
| Agent (Agent) | Launch an agentic coding workflow. | Open in Stable or Preview. With minimal guidance, autonomously implement new features or advanced project requirements, invoke tools to perform specialized tasks, and iteratively resolve issues as they arise. |
You can switch between different chat modes by using the mode dropdown menu in the chat view.
