edit-prediction.md

  1# Edit Prediction
  2
  3Edit Prediction is Zed's LLM mechanism for predicting the code you want to write.
  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), but you can also use [other providers](#other-providers) like GitHub Copilot, Supermaven, and Codestral.
  7
  8## Configuring Zeta
  9
 10To use Zeta, the only thing you need to do is [to sign in](../authentication.md#what-features-require-signing-in).
 11After doing that, you should already see predictions as you type on your files.
 12
 13You can confirm that Zeta is properly configured either by verifying whether you have the following code in your `settings.json`:
 14
 15```json [settings]
 16"features": {
 17  "edit_prediction_provider": "zed"
 18},
 19```
 20
 21Or you can also look for a little Z icon in the right of your status bar at the bottom.
 22
 23### Pricing and Plans
 24
 25From just signing in, while in Zed's free plan, you get 2,000 Zeta-powered edit predictions per month.
 26But you can get _**unlimited edit predictions**_ by upgrading to [the Pro plan](../ai/plans-and-usage.md).
 27More information can be found in [Zed's pricing page](https://zed.dev/pricing).
 28
 29### Switching Modes {#switching-modes}
 30
 31Zed's Edit Prediction comes with two different display modes:
 32
 331. `eager` (default): predictions are displayed inline as long as it doesn't conflict with language server completions
 342. `subtle`: predictions only appear inline when holding a modifier key (`alt` by default)
 35
 36Toggle between them via the `mode` key:
 37
 38```json [settings]
 39"edit_predictions": {
 40  "mode": "eager" // or "subtle"
 41},
 42```
 43
 44Or directly via the UI through the status bar menu:
 45
 46![Edit Prediction status bar menu, with the modes toggle.](https://zed.dev/img/edit-prediction/status-bar-menu.webp)
 47
 48> Note that edit prediction modes work with any prediction provider.
 49
 50### Conflict With Other `tab` Actions {#edit-predictions-conflict}
 51
 52By default, when `tab` would normally perform a different action, Zed requires a modifier key to accept predictions:
 53
 541. When the language server completions menu is visible.
 552. When your cursor isn't at the right indentation level.
 56
 57In 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.
 58
 59On 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.
 60
 61{#action editor::AcceptNextWordEditPrediction} ({#kb editor::AcceptNextWordEditPrediction}) can be used to accept the current edit prediction up to the next word boundary.
 62{#action editor::AcceptNextLineEditPrediction} ({#kb editor::AcceptNextLineEditPrediction}) can be used to accept the current edit prediction up to the new line boundary.
 63
 64## Configuring Edit Prediction Keybindings {#edit-predictions-keybinding}
 65
 66By default, `tab` is used to accept edit predictions. You can use another keybinding by inserting this in your keymap:
 67
 68```json [settings]
 69{
 70  "context": "Editor && edit_prediction",
 71  "bindings": {
 72    // Here we also allow `alt-enter` to accept the prediction
 73    "alt-enter": "editor::AcceptEditPrediction"
 74  }
 75}
 76```
 77
 78When there's a [conflict with the `tab` key](#edit-predictions-conflict), Zed uses a different key context to accept keybindings (`edit_prediction_conflict`).
 79If you want to use a different one, you can insert this in your keymap:
 80
 81```json [settings]
 82{
 83  "context": "Editor && edit_prediction_conflict",
 84  "bindings": {
 85    "ctrl-enter": "editor::AcceptEditPrediction" // Example of a modified keybinding
 86  }
 87}
 88```
 89
 90If 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.
 91
 92You can also bind this action to keybind without a modifier.
 93In that case, Zed will use the default modifier (`alt`) to preview the edit prediction.
 94
 95```json [settings]
 96{
 97  "context": "Editor && edit_prediction_conflict",
 98  "bindings": {
 99    // Here we bind tab to accept even when there's a language server completion
100    // or the cursor isn't at the correct indentation level
101    "tab": "editor::AcceptEditPrediction"
102  }
103}
104```
105
106To 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`:
107
108```json [settings]
109{
110  "context": "Editor && edit_prediction_conflict && !showing_completions",
111  "bindings": {
112    // Here we don't require a modifier unless there's a language server completion
113    "tab": "editor::AcceptEditPrediction"
114  }
115}
116```
117
118### Keybinding Example: Always Use Tab
119
120If you want to use `tab` to always accept edit predictions, you can use the following keybinding:
121
122```json [keymap]
123{
124  "context": "Editor && edit_prediction_conflict && showing_completions",
125  "bindings": {
126    "tab": "editor::AcceptEditPrediction"
127  }
128}
129```
130
131This will make `tab` work to accept edit predictions _even when_ you're also seeing language server completions.
132That means that you need to rely on `enter` for accepting the latter.
133
134### Keybinding Example: Always Use Alt-Tab
135
136The keybinding example below causes `alt-tab` to always be used instead of sometimes using `tab`.
137You might want this in order to have just one (alternative) keybinding to use for accepting edit predictions, since the behavior of `tab` varies based on context.
138
139```json [keymap]
140  {
141    "context": "Editor && edit_prediction",
142    "bindings": {
143      "alt-tab": "editor::AcceptEditPrediction"
144    }
145  },
146  // Bind `tab` back to its original behavior.
147  {
148    "context": "Editor",
149    "bindings": {
150      "tab": "editor::Tab"
151    }
152  },
153  {
154    "context": "Editor && showing_completions",
155    "bindings": {
156      "tab": "editor::ComposeCompletion"
157    }
158  },
159```
160
161If you are using [Vim mode](../vim.md), then additional bindings are needed after the above to return `tab` to its original behavior:
162
163```json [keymap]
164  {
165    "context": "(VimControl && !menu) || vim_mode == replace || vim_mode == waiting",
166    "bindings": {
167      "tab": "vim::Tab"
168    }
169  },
170  {
171    "context": "vim_mode == literal",
172    "bindings": {
173      "tab": ["vim::Literal", ["tab", "\u0009"]]
174    }
175  },
176```
177
178### Keybinding Example: Displaying Tab and Alt-Tab on Linux
179
180While `tab` and `alt-tab` are supported on Linux, `alt-l` is displayed instead.
181If your window manager does not reserve `alt-tab`, and you would prefer to use `tab` and `alt-tab`, include these bindings in `keymap.json`:
182
183```json [keymap]
184  {
185    "context": "Editor && edit_prediction",
186    "bindings": {
187      "tab": "editor::AcceptEditPrediction",
188      // Optional: This makes the default `alt-l` binding do nothing.
189      "alt-l": null
190    }
191  },
192  {
193    "context": "Editor && edit_prediction_conflict",
194    "bindings": {
195      "alt-tab": "editor::AcceptEditPrediction",
196      // Optional: This makes the default `alt-l` binding do nothing.
197      "alt-l": null
198    }
199  },
200```
201
202### Missing keybind {#edit-predictions-missing-keybinding}
203
204Zed 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)).
205
206If 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:
207
208```json [keymap]
209[
210  // Your keymap
211  {
212    "bindings": {
213      // Binds `alt-tab` to a different action globally
214      "alt-tab": "menu::SelectNext"
215    }
216  }
217]
218```
219
220To fix this, you can specify your own keybinding for accepting edit predictions:
221
222```json [keymap]
223[
224  // ...
225  {
226    "context": "Editor && edit_prediction_conflict",
227    "bindings": {
228      "alt-l": "editor::AcceptEditPrediction"
229    }
230  }
231]
232```
233
234If 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.
235
236## Disabling Automatic Edit Prediction
237
238There are different levels in which you can disable edit predictions to be displayed, including not having it turned on at all.
239
240Alternatively, if you have Zed set as your provider, consider [using Subtle Mode](#switching-modes).
241
242### On Buffers
243
244To not have predictions appear automatically as you type, set this within `settings.json`:
245
246```json [settings]
247{
248  "show_edit_predictions": false
249}
250```
251
252This 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).
253Still, you can trigger edit predictions manually by executing {#action editor::ShowEditPrediction} or hitting {#kb editor::ShowEditPrediction}.
254
255### For Specific Languages
256
257To not have predictions appear automatically as you type when working with a specific language, set this within `settings.json`:
258
259```json [settings]
260{
261  "language": {
262    "python": {
263      "show_edit_predictions": false
264    }
265  }
266}
267```
268
269### In Specific Directories
270
271To disable edit predictions for specific directories or files, set this within `settings.json`:
272
273```json [settings]
274{
275  "edit_predictions": {
276    "disabled_globs": ["~/.config/zed/settings.json"]
277  }
278}
279```
280
281### Turning Off Completely
282
283To completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so:
284
285```json [settings]
286"features": {
287  "edit_prediction_provider": "none"
288},
289```
290
291## Configuring Other Providers {#other-providers}
292
293Zed's Edit Prediction also work with other completion model providers aside from Zeta.
294Learn about the available ones below.
295
296### GitHub Copilot {#github-copilot}
297
298To use GitHub Copilot as your provider, set this within `settings.json`:
299
300```json [settings]
301{
302  "features": {
303    "edit_prediction_provider": "copilot"
304  }
305}
306```
307
308To sign in to GitHub Copilot, click on the Copilot icon in the status bar. A popup window appears displaying a device code. Click the copy button to copy the code, then click "Connect to GitHub" to open the GitHub verification page in your browser. Paste the code when prompted. The popup window closes automatically after successful authorization.
309
310#### Using GitHub Copilot Enterprise
311
312If your organization uses GitHub Copilot Enterprise, you can configure Zed to use your enterprise instance by specifying the enterprise URI in your `settings.json`:
313
314```json [settings]
315{
316  "edit_predictions": {
317    "copilot": {
318      "enterprise_uri": "https://your.enterprise.domain"
319    }
320  }
321}
322```
323
324Replace `"https://your.enterprise.domain"` with the URL provided by your GitHub Enterprise administrator (e.g., `https://foo.ghe.com`).
325
326Once set, Zed will route Copilot requests through your enterprise endpoint.
327When you sign in by clicking the Copilot icon in the status bar, you will be redirected to your configured enterprise URL to complete authentication.
328All other Copilot features and usage remain the same.
329
330Copilot can provide multiple completion alternatives, and these can be navigated with the following actions:
331
332- {#action editor::NextEditPrediction} ({#kb editor::NextEditPrediction}): To cycle to the next edit prediction
333- {#action editor::PreviousEditPrediction} ({#kb editor::PreviousEditPrediction}): To cycle to the previous edit prediction
334
335### Supermaven {#supermaven}
336
337To use Supermaven as your provider, set this within `settings.json`:
338
339```json [settings]
340{
341  "features": {
342    "edit_prediction_provider": "supermaven"
343  }
344}
345```
346
347You should be able to sign-in to Supermaven by clicking on the Supermaven icon in the status bar and following the setup instructions.
348
349### Codestral {#codestral}
350
351<<<<<<< Updated upstream
352To use Mistral's Codestral as your provider:
353=======
354To use Mistral's Codestral as your provider, open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) and navigate to the Edit Predictions section. Select Codestral as your provider and enter your API key in the corresponding field.
355
356> > > > > > > Stashed changes
357
3581. Open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows)
3592. Search for "Edit Predictions" and click **Configure Providers**
3603. Find the Codestral section and enter your API key from the
361   [Codestral dashboard](https://console.mistral.ai/codestral)
362
363Alternatively, click the edit prediction icon in the status bar and select
364**Configure Providers** from the menu.
365
366After adding your API key, set Codestral as your provider in `settings.json`:
367
368```json [settings]
369{
370  "features": {
371    "edit_prediction_provider": "codestral"
372  }
373}
374```
375
376## See also
377
378To 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.