1# Edit Prediction
2
3Edit Prediction is Zed's mechanism for predicting the code you want to write through AI.
4Each keystroke sends a new request to the edit prediction provider, which returns individual or multi-line suggestions that can be quickly accepted by pressing `tab`.
5
6The default provider is [Zeta, a proprietary open source and open dataset model](https://huggingface.co/zed-industries/zeta), which [requires being signed into Zed](../authentication.md#what-features-require-signing-in).
7
8Alternatively, you can use other providers like [GitHub Copilot](#github-copilot) (or [Enterprise](#github-copilot-enterprise)) or [Supermaven](#supermaven).
9
10## Configuring Zeta
11
12Zed's Edit Prediction was initially introduced via a banner on the title bar.
13Clicking on it would take you to a modal with a button ("Enable Edit Prediction") that sets `zed` as your `edit_prediction_provider`.
14
15
16
17But, if you haven't come across the banner, Zed's Edit Prediction is the default edit prediction provider and you should see it right away in your status bar.
18
19### Switching Modes {#switching-modes}
20
21Zed's Edit Prediction comes with two different display modes:
22
231. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
242. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
25
26Toggle between them via the `mode` key:
27
28```json [settings]
29"edit_predictions": {
30 "mode": "eager" // or "subtle"
31},
32```
33
34Or directly via the UI through the status bar menu:
35
36
37
38### Conflict With Other `tab` Actions {#edit-predictions-conflict}
39
40By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
41
421. When the language server completions menu is visible.
432. When your cursor isn't at the right indentation level.
44
45In these cases, `alt-tab` is used instead to accept the prediction. When the language server completions menu is open, holding `alt` first will cause it to temporarily disappear in order to preview the prediction within the buffer.
46
47On Linux, `alt-tab` is often used by the window manager for switching windows, so `alt-l` is provided as the default binding for accepting predictions. `tab` and `alt-tab` also work, but aren't displayed by default.
48
49{#action editor::AcceptPartialEditPrediction} ({#kb editor::AcceptPartialEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
50
51See the [Configuring GitHub Copilot](#github-copilot) and [Configuring Supermaven](#supermaven) sections below for configuration of other providers. Only text insertions at the current cursor are supported for these providers, whereas the Zeta model provides multiple predictions including deletions.
52
53## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
54
55By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
56
57```json [settings]
58{
59 "context": "Editor && edit_prediction",
60 "bindings": {
61 // Here we also allow `alt-enter` to accept the prediction
62 "alt-enter": "editor::AcceptEditPrediction"
63 }
64}
65```
66
67When there's a [conflict with the `tab` key](#edit-predictions-conflict), Zed uses a different context to accept keybindings (`edit_prediction_conflict`). If you want to use a different one, you can insert this in your keymap:
68
69```json [settings]
70{
71 "context": "Editor && edit_prediction_conflict",
72 "bindings": {
73 "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
74 }
75}
76```
77
78If your keybinding contains a modifier (`ctrl` in the example above), it will also be used to preview the edit prediction and temporarily hide the language server completion menu.
79
80You can also bind this action to keybind without a modifier. In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
81
82```json [settings]
83{
84 "context": "Editor && edit_prediction_conflict",
85 "bindings": {
86 // Here we bind tab to accept even when there's a language server completion
87 // or the cursor isn't at the correct indentation level
88 "tab": "editor::AcceptEditPrediction"
89 }
90}
91```
92
93To maintain the use of the modifier key for accepting predictions when there is a language server completions menu, but allow `tab` to accept predictions regardless of cursor position, you can specify the context further with `showing_completions`:
94
95```json [settings]
96{
97 "context": "Editor && edit_prediction_conflict && !showing_completions",
98 "bindings": {
99 // Here we don't require a modifier unless there's a language server completion
100 "tab": "editor::AcceptEditPrediction"
101 }
102}
103```
104
105### Keybinding Example: Always Use Alt-Tab
106
107The keybinding example below causes `alt-tab` to always be used instead of sometimes using `tab`. You might want this in order to have just one keybinding to use for accepting edit predictions, since the behavior of `tab` varies based on context.
108
109```json [keymap]
110 {
111 "context": "Editor && edit_prediction",
112 "bindings": {
113 "alt-tab": "editor::AcceptEditPrediction"
114 }
115 },
116 // Bind `tab` back to its original behavior.
117 {
118 "context": "Editor",
119 "bindings": {
120 "tab": "editor::Tab"
121 }
122 },
123 {
124 "context": "Editor && showing_completions",
125 "bindings": {
126 "tab": "editor::ComposeCompletion"
127 }
128 },
129```
130
131If `"vim_mode": true` is set within `settings.json`, then additional bindings are needed after the above to return `tab` to its original behavior:
132
133```json [keymap]
134 {
135 "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
136 "bindings": {
137 "tab": "vim::Tab"
138 }
139 },
140 {
141 "context": "vim_mode == literal",
142 "bindings": {
143 "tab": ["vim::Literal", ["tab", "\u0009"]]
144 }
145 },
146```
147
148### Keybinding Example: Displaying Tab and Alt-Tab on Linux
149
150While `tab` and `alt-tab` are supported on Linux, `alt-l` is displayed instead. If your window manager does not reserve `alt-tab`, and you would prefer to use `tab` and `alt-tab`, include these bindings in `keymap.json`:
151
152```json [keymap]
153 {
154 "context": "Editor && edit_prediction",
155 "bindings": {
156 "tab": "editor::AcceptEditPrediction",
157 // Optional: This makes the default `alt-l` binding do nothing.
158 "alt-l": null
159 }
160 },
161 {
162 "context": "Editor && edit_prediction_conflict",
163 "bindings": {
164 "alt-tab": "editor::AcceptEditPrediction",
165 // Optional: This makes the default `alt-l` binding do nothing.
166 "alt-l": null
167 }
168 },
169```
170
171### Missing keybind {#edit-predictions-missing-keybinding}
172
173Zed requires at least one keybinding for the {#action editor::AcceptEditPrediction} action in both the `Editor && edit_prediction` and `Editor && edit_prediction_conflict` contexts ([learn more above](#edit-predictions-keybinding)).
174
175If you have previously bound the default keybindings to different actions in the global context, you will not be able to preview or accept edit predictions. For example:
176
177```json [keymap]
178[
179 // Your keymap
180 {
181 "bindings": {
182 // Binds `alt-tab` to a different action globally
183 "alt-tab": "menu::SelectNext"
184 }
185 }
186]
187```
188
189To fix this, you can specify your own keybinding for accepting edit predictions:
190
191```json [keymap]
192[
193 // ...
194 {
195 "context": "Editor && edit_prediction_conflict",
196 "bindings": {
197 "alt-l": "editor::AcceptEditPrediction"
198 }
199 }
200]
201```
202
203If you would like to use the default keybinding, you can free it up by either moving yours to a more specific context or changing it to something else.
204
205## Disabling Automatic Edit Prediction
206
207There are different levels in which you can disable edit predictions to be displayed, including not having it turned on at all.
208
209Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
210
211### On Buffers
212
213To not have predictions appear automatically as you type, set this within `settings.json`:
214
215```json [settings]
216{
217 "show_edit_predictions": false
218}
219```
220
221This hides every indication that there is a prediction available, regardless of [the display mode](#switching-modes) you're in (valid only if you have Zed as your provider).
222Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
223
224### For Specific Languages
225
226To not have predictions appear automatically as you type when working with a specific language, set this within `settings.json`:
227
228```json [settings]
229{
230 "language": {
231 "python": {
232 "show_edit_predictions": false
233 }
234 }
235}
236```
237
238### In Specific Directories
239
240To disable edit predictions for specific directories or files, set this within `settings.json`:
241
242```json [settings]
243{
244 "edit_predictions": {
245 "disabled_globs": ["~/.config/zed/settings.json"]
246 }
247}
248```
249
250### Turning Off Completely
251
252To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
253
254```json [settings]
255"features": {
256 "edit_prediction_provider": "none"
257},
258```
259
260## Configuring GitHub Copilot {#github-copilot}
261
262To use GitHub Copilot as your provider, set this within `settings.json`:
263
264```json [settings]
265{
266 "features": {
267 "edit_prediction_provider": "copilot"
268 }
269}
270```
271
272You should be able to sign-in to GitHub Copilot by clicking on the Copilot icon in the status bar and following the setup instructions.
273
274### Using GitHub Copilot Enterprise {#github-copilot-enterprise}
275
276If your organization uses GitHub Copilot Enterprise, you can configure Zed to use your enterprise instance by specifying the enterprise URI in your `settings.json`:
277
278```json [settings]
279{
280 "edit_predictions": {
281 "copilot": {
282 "enterprise_uri": "https://your.enterprise.domain"
283 }
284 }
285}
286```
287
288Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
289
290Once set, Zed will route Copilot requests through your enterprise endpoint. When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication. All other Copilot features and usage remain the same.
291
292Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
293
294- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
295- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
296
297## Configuring Supermaven {#supermaven}
298
299To use Supermaven as your provider, set this within `settings.json`:
300
301```json [settings]
302{
303 "features": {
304 "edit_prediction_provider": "supermaven"
305 }
306}
307```
308
309You should be able to sign-in to Supermaven by clicking on the Supermaven icon in the status bar and following the setup instructions.
310
311## See also
312
313You may also use the [Agent Panel](./agent-panel.md) or the [Inline Assistant](./inline-assistant.md) to interact with language models, see the [AI documentation](./overview.md) for more information on the other AI features in Zed.