edit-prediction.md

  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).
  7Alternatively, you can also use [other providers](#other-providers) like GitHub Copilot and Codestral.
  8
  9## Configuring Zeta
 10
 11Zed's Edit Prediction was initially introduced via a banner on the title bar.
 12Clicking on it would take you to a modal with a button ("Enable Edit Prediction") that sets `zed` as your `edit_prediction_provider`.
 13
 14![Onboarding banner and modal](https://zed.dev/img/edit-prediction/docs.webp)
 15
 16But, 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.
 17
 18### Switching Modes {#switching-modes}
 19
 20Zed's Edit Prediction comes with two different display modes:
 21
 221. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
 232. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
 24
 25Toggle between them via the `mode` key:
 26
 27```json [settings]
 28"edit_predictions": {
 29  "mode": "eager" // or "subtle"
 30},
 31```
 32
 33Or directly via the UI through the status bar menu:
 34
 35![Edit Prediction status bar menu, with the modes toggle.](https://zed.dev/img/edit-prediction/status-bar-menu.webp)
 36
 37### Conflict With Other `tab` Actions {#edit-predictions-conflict}
 38
 39By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
 40
 411. When the language server completions menu is visible.
 422. When your cursor isn't at the right indentation level.
 43
 44In 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.
 45
 46On 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.
 47
 48{#action editor::AcceptPartialEditPrediction} ({#kb editor::AcceptPartialEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
 49
 50See 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.
 51
 52## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
 53
 54By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
 55
 56```json [settings]
 57{
 58  "context": "Editor && edit_prediction",
 59  "bindings": {
 60    // Here we also allow `alt-enter` to accept the prediction
 61    "alt-enter": "editor::AcceptEditPrediction"
 62  }
 63}
 64```
 65
 66When 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:
 67
 68```json [settings]
 69{
 70  "context": "Editor && edit_prediction_conflict",
 71  "bindings": {
 72    "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
 73  }
 74}
 75```
 76
 77If 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.
 78
 79You 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.
 80
 81```json [settings]
 82{
 83  "context": "Editor && edit_prediction_conflict",
 84  "bindings": {
 85    // Here we bind tab to accept even when there's a language server completion
 86    // or the cursor isn't at the correct indentation level
 87    "tab": "editor::AcceptEditPrediction"
 88  }
 89}
 90```
 91
 92To 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`:
 93
 94```json [settings]
 95{
 96  "context": "Editor && edit_prediction_conflict && !showing_completions",
 97  "bindings": {
 98    // Here we don't require a modifier unless there's a language server completion
 99    "tab": "editor::AcceptEditPrediction"
100  }
101}
102```
103
104### Keybinding Example: Always Use Alt-Tab
105
106The 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.
107
108```json [keymap]
109  {
110    "context": "Editor && edit_prediction",
111    "bindings": {
112      "alt-tab": "editor::AcceptEditPrediction"
113    }
114  },
115  // Bind `tab` back to its original behavior.
116  {
117    "context": "Editor",
118    "bindings": {
119      "tab": "editor::Tab"
120    }
121  },
122  {
123    "context": "Editor && showing_completions",
124    "bindings": {
125      "tab": "editor::ComposeCompletion"
126    }
127  },
128```
129
130If `"vim_mode": true` is set within `settings.json`, then additional bindings are needed after the above to return `tab` to its original behavior:
131
132```json [keymap]
133  {
134    "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
135    "bindings": {
136      "tab": "vim::Tab"
137    }
138  },
139  {
140    "context": "vim_mode == literal",
141    "bindings": {
142      "tab": ["vim::Literal", ["tab", "\u0009"]]
143    }
144  },
145```
146
147### Keybinding Example: Displaying Tab and Alt-Tab on Linux
148
149While `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`:
150
151```json [keymap]
152  {
153    "context": "Editor && edit_prediction",
154    "bindings": {
155      "tab": "editor::AcceptEditPrediction",
156      // Optional: This makes the default `alt-l` binding do nothing.
157      "alt-l": null
158    }
159  },
160  {
161    "context": "Editor && edit_prediction_conflict",
162    "bindings": {
163      "alt-tab": "editor::AcceptEditPrediction",
164      // Optional: This makes the default `alt-l` binding do nothing.
165      "alt-l": null
166    }
167  },
168```
169
170### Missing keybind {#edit-predictions-missing-keybinding}
171
172Zed 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)).
173
174If 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:
175
176```json [keymap]
177[
178  // Your keymap
179  {
180    "bindings": {
181      // Binds `alt-tab` to a different action globally
182      "alt-tab": "menu::SelectNext"
183    }
184  }
185]
186```
187
188To fix this, you can specify your own keybinding for accepting edit predictions:
189
190```json [keymap]
191[
192  // ...
193  {
194    "context": "Editor && edit_prediction_conflict",
195    "bindings": {
196      "alt-l": "editor::AcceptEditPrediction"
197    }
198  }
199]
200```
201
202If 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.
203
204## Disabling Automatic Edit Prediction
205
206There are different levels in which you can disable edit predictions to be displayed, including not having it turned on at all.
207
208Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
209
210### On Buffers
211
212To not have predictions appear automatically as you type, set this within `settings.json`:
213
214```json [settings]
215{
216  "show_edit_predictions": false
217}
218```
219
220This 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).
221Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
222
223### For Specific Languages
224
225To not have predictions appear automatically as you type when working with a specific language, set this within `settings.json`:
226
227```json [settings]
228{
229  "language": {
230    "python": {
231      "show_edit_predictions": false
232    }
233  }
234}
235```
236
237### In Specific Directories
238
239To disable edit predictions for specific directories or files, set this within `settings.json`:
240
241```json [settings]
242{
243  "edit_predictions": {
244    "disabled_globs": ["~/.config/zed/settings.json"]
245  }
246}
247```
248
249### Turning Off Completely
250
251To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
252
253```json [settings]
254"features": {
255  "edit_prediction_provider": "none"
256},
257```
258
259## Configuring Other Providers {#other-providers}
260
261Zed's Edit Prediction also work with other completion model providers aside from Zeta.
262Learn about the available ones below.
263
264### GitHub Copilot {#github-copilot}
265
266To use GitHub Copilot as your provider, set this within `settings.json`:
267
268```json [settings]
269{
270  "features": {
271    "edit_prediction_provider": "copilot"
272  }
273}
274```
275
276You should be able to sign-in to GitHub Copilot by clicking on the Copilot icon in the status bar and following the setup instructions.
277
278#### Using GitHub Copilot Enterprise
279
280If your organization uses GitHub Copilot Enterprise, you can configure Zed to use your enterprise instance by specifying the enterprise URI in your `settings.json`:
281
282```json [settings]
283{
284  "edit_predictions": {
285    "copilot": {
286      "enterprise_uri": "https://your.enterprise.domain"
287    }
288  }
289}
290```
291
292Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
293
294Once set, Zed will route Copilot requests through your enterprise endpoint.
295When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication.
296All other Copilot features and usage remain the same.
297
298Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
299
300- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
301- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
302
303### Supermaven {#supermaven}
304
305To use Supermaven as your provider, set this within `settings.json`:
306
307```json [settings]
308{
309  "features": {
310    "edit_prediction_provider": "supermaven"
311  }
312}
313```
314
315You should be able to sign-in to Supermaven by clicking on the Supermaven icon in the status bar and following the setup instructions.
316
317### Configuring Supermaven {#supermaven}
318
319To use Mistral's Codestral as your provider, start by going to the the Agent Panel settings view by running the {#action agent::OpenSettings} action.
320Look for the Mistral item and add a Codestral API key in the corresponding text input.
321
322After that, you should be able to switch your provider to it in your `settings.json` file:
323
324```json [settings]
325{
326  "features": {
327    "edit_prediction_provider": "codestral"
328  }
329}
330```
331
332## See also
333
334To learn about other ways to interact with AI in Zed, you may also want to see more about the [Agent Panel](./agent-panel.md) or the [Inline Assistant](./inline-assistant.md) feature.