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