You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GitHub Copilot acts as an AI-powered pair programmer, automatically offering suggestions to complete your code, comments, tests, and more. It provides these suggestions directly in the editor while you write your code, and it can work with a broad range of programming languages and frameworks.
14
14
15
+
Copilot provides two kinds of suggestions:
16
+
***Code completions** - Start typing in the editor, and Copilot provides code suggestions that match your coding style and take your existing code into account.
17
+
***Next Edit Suggestions (preview)** - Predict your next code edit with Copilot Next Edit Suggestions, aka Copilot NES. Based on the edits you're making, NES both predicts the location of the next edit you'll want to make and what that edit should be.
18
+
19
+
## Getting started
20
+
21
+
1. Install the GitHub Copilot extensions.
22
+
23
+
> <aclass="install-extension-btn"href="vscode:extension/GitHub.copilot?referrer=docs-copilot-ai-powered-suggestions">Install the GitHub Copilot extensions</a>
24
+
25
+
1. Sign in with your GitHub account to use Copilot.
26
+
27
+
> [!TIP]
28
+
> If you don't yet have a Copilot subscription, you can use Copilot for free by signing up for the [Copilot Free plan](https://github.com/github-copilot/signup) and get a monthly limit of completions and chat interactions.
29
+
30
+
1. Discover the key features of Copilot in VS Code with our [Copilot Quickstart](/docs/copilot/getting-started.md).
31
+
15
32
## Inline suggestions
16
33
17
34
Copilot offers code suggestions as you type: sometimes the completion of the current line, sometimes a whole new block of code. You can accept all, or part of a suggestion, or you can keep typing and ignore the suggestions.
@@ -44,7 +61,85 @@ The following example shows how to instruct Copilot to create a class in TypeScr
44
61
45
62

46
63
47
-
## Enable or disable inline suggestions
64
+
## Next Edit Suggestions (preview)
65
+
66
+
Inline suggestions are great at autocompleting a section of code. But since most coding activity is editing existing code, it's a natural evolution of Copilot code completions to also help with edits, both at the cursor and further away. Edits are often not made in isolation - there's a logical flow of what edits need to be made in different scenarios. Copilot Next Edit Suggestions (aka "Copilot NES") is this evolution.
67
+
68
+
<videosrc="./images/inline-suggestions/nes-video.mp4"title="Copilot NES video"controlsposter="./images/inline-suggestions/point3d.png"></video>
69
+
70
+
Based on the edits you're making, Copilot NES both predicts the location of the next edit you'll want to make and what that edit should be. NES helps you stay in the flow, suggesting future changes relevant to your current work, and you can simply `kbstyle(Tab)` to quickly navigate and accept Copilot's suggestions. Suggestions may span a single symbol, an entire line, or multiple lines, depending on the scope of the potential change.
71
+
72
+
### Enabling edit suggestions
73
+
74
+
Copilot NES is currently in preview. You can enable NES via the VS Code setting `setting(github.copilot.nextEditSuggestions.enabled)`, using the following steps:
75
+
* Open the VS Code Settings editor (`kb(workbench.action.openSettings)`)
76
+
* Search for `setting(github.copilot.nextEditSuggestions.enabled)`
77
+
* Enable the setting
78
+
79
+
If you are a Copilot Business or Enterprise user, an administrator of your organization must opt in to the use of Copilot editor preview features, in addition to you setting `setting(github.copilot.nextEditSuggestions.enabled)` in your editor.
80
+
81
+
You can learn more about [managing policies for Copilot in your organization](https://docs.github.com/en/copilot/managing-copilot/managing-github-copilot-in-your-organization/managing-policies-for-copilot-in-your-organization#enabling-copilot-features-in-your-organization).
82
+
83
+
### Navigate and accept edit suggestions
84
+
85
+
You can quickly navigate suggested code changes with the `kbstyle(Tab)` key, saving you time to find the next relevant edit (no manual searching through files or references required). You can then accept a suggestion with the `kbstyle(Tab)` key again.
86
+
87
+
An arrow in the gutter indicates if there is an edit suggestion available. You can hover over the arrow to explore the edit suggestion menu, which includes keyboard shortcuts and settings configuration:
88
+

89
+
90
+
If an edit suggestion is below the current editor view, the arrow will point down instead of right:
91
+

92
+
<!--  -->
93
+
<!--  -->
94
+
95
+
### Use cases for Next Edit Suggestions
96
+
97
+
**Catching and correcting mistakes**
98
+
99
+
***Copilot helps with simple mistakes like typos.** It'll suggest fixes where letters are missing or swapped, like `cont x = 5` or `conts x = 5`, which should've been `const x = 5`.
100
+

101
+
***Copilot can also help with more challenging mistakes in logic**, like an inverted ternary expression:
102
+

103
+
Or a comparison that should've used `&&` instead of `||`:
104
+

105
+
106
+
**Changing intent**
107
+
108
+
***Copilot suggests changes to the rest of your code that match a new change in intent.** For example, when changing a class from `Point` to `Point3D`, Copilot will suggest to add a `z` variable to the class definition. After accepting the change, NES next recommends adding `z` to the distance calculation:
109
+

110
+
<!-- 
111
+
 -->
112
+
113
+
**Adding new variables or logic**
114
+
115
+
***Using newly added arguments, variables, or functions**. Copilot helps you use new code you just added. This may be a small change, like calling a new method parameter in the actual method.
116
+
117
+
It could also be more complex: if you added a new command to your VS Code extension's `extension.ts`, Copilot will first suggest to clean up the command in `extension.ts`. Then when you open `package.json`, Copilot suggests registering that command as well:
118
+

119
+
<!-- 
120
+
 -->
121
+
122
+
**Refactoring**
123
+
124
+
***Rename a variable once in a file, and Copilot will suggest to update it everywhere else.** If you use a new name or naming pattern, Copilot suggests to update subsequent code similarly.
125
+

126
+
***Matching code style**. After copy-pasting some code, Copilot will suggest how to adjust it to match the current code where the paste happened.
127
+
128
+
### Further configuring edit suggestions
129
+
130
+
You use Copilot NES, you must set `setting(github.copilot.nextEditSuggestions.enabled)`. There are a couple of additional settings you can also use to configure your NES experience:
131
+
*`setting(editor.inlineSuggest.edits.codeShifting)`: You can disable this setting if you never want NES to shift your code to show a suggestion.
***auto (default)**: Show larger suggestions side-by-side if there is enough space in the viewport, otherwise the suggestions is shown below the relevant code.
134
+
***never**: Always show larger suggestions below the relevant code.
135
+
136
+
## Tips & tricks
137
+
138
+
### Context
139
+
140
+
To give you relevant inline suggestions, Copilot looks at the current and open files in your editor to analyze the context and create appropriate suggestions. Having related files open in VS Code while using Copilot helps set this context and lets Copilot get a bigger picture of your project.
141
+
142
+
### Enable or disable code completions
48
143
49
144
You can temporarily enable or disable code completions either for all languages, or for specific languages only.
50
145
@@ -61,12 +156,6 @@ You can temporarily enable or disable code completions either for all languages,
61
156
62
157

63
158
64
-
## Tips & tricks
65
-
66
-
### Context
67
-
68
-
To give you relevant inline suggestions, Copilot looks at the current and open files in your editor to analyze the context and create appropriate suggestions. Having related files open in VS Code while using Copilot helps set this context and lets the Copilot see a bigger picture of your project.
69
-
70
159
### Settings
71
160
72
161
*`setting(editor.inlineSuggest.enabled)` - enable or disable inline completions.
@@ -77,6 +166,12 @@ To give you relevant inline suggestions, Copilot looks at the current and open f
77
166
78
167
*`setting(editor.inlineSuggest.syntaxHighlightingEnabled)` - enable or disable syntax highlighting for inline completions.
79
168
169
+
*`setting(github.copilot.nextEditSuggestions.enabled)` - enable Copilot Next Edit Suggestions (Copilot NES).
170
+
171
+
*`setting(editor.inlineSuggest.edits.codeShifting)` - configure if NES is able to shift your code to show a suggestion.
172
+
173
+
*`setting(editor.inlineSuggest.edits.renderSideBySide)` - configure if NES can show larger suggestions side-by-side if possible, or if NES should always show larger suggestions below the relevant code.
174
+
80
175
## Next steps
81
176
82
177
* Get started with the introductory [Copilot tutorial](/docs/copilot/getting-started-chat.md) to get set up with Copilot in VS Code and experience Copilot hands-on.
Copy file name to clipboardExpand all lines: docs/copilot/copilot-settings.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,9 @@ The team is continuously working on improving Copilot in VS Code and adding new
26
26
*`setting(chat.commandCenter.enabled)` <iclass="codicon codicon-beaker"></i>: Controls whether the command center shows a menu for chat actions.
27
27
*`setting(workbench.commandPalette.experimental.askChatLocation)` <iclass="codicon codicon-beaker"></i>: Controls where the Command Palette should ask chat questions.
28
28
*`setting(github.copilot.chat.search.semanticTextResults)` <iclass="codicon codicon-beaker"></i>: Enables semantic search results in the Search view.
*`setting(editor.inlineSuggest.edits.codeShifting)` <iclass="codicon codicon-beaker"></i>: Configure if NES is able to shift your code to show a suggestion.
31
+
*`setting(editor.inlineSuggest.edits.renderSideBySide)` <iclass="codicon codicon-beaker"></i>: Configure if NES can show larger suggestions side-by-side if possible, or if NES should always show larger suggestions below the relevant code.
Copy file name to clipboardExpand all lines: docs/copilot/copilot-vscode-features.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,7 @@ As you're coding in the editor, you can use Copilot to generate code completions
114
114
| Action | Description |
115
115
|--------|-------------|
116
116
| Code completions | Start typing in the editor and Copilot provides code suggestions that match your coding style and take your existing code into account. |
117
+
| Next Edit Suggestions (preview) | Predict your next code edit with Copilot Next Edit Suggestions, aka Copilot NES. Based on the edits you're making, NES both predicts the location of the next edit you'll want to make and what that edit should be. You can enable NES via the VS Code setting `setting(github.copilot.nextEditSuggestions.enabled)`. |
117
118
| Code comments | Provide a code completion prompt to Copilot by writing instructions in a code comment.<br/>Example: `# write a calculator class with methods for add, subtract, and multiply. Use static methods.`|
118
119
|`kb(inlinechat.start)`| Start **Inline Chat** to send a chat request to Copilot directly from the editor. Use natural language or use `/` commands to give instructions to Copilot. |
119
120
| Prompt from the editor <iclass="codicon codicon-beaker"></i> | Start typing natural language directly in code and Copilot detects that you're not writing code but prompting, and will automatically start Inline Chat for your prompt. |
0 commit comments