1# Key bindings
2
3Zed can be configured via a simple JSON file located at `~/.config/zed/keymap.json`.
4
5## Predefined keymaps
6
7We have a growing collection of pre-defined keymaps in [zed repository's keymaps folder](https://github.com/zed-industries/zed/tree/main/assets/keymaps). Our current keymaps include:
8
9- Atom
10- JetBrains
11- SublimeText
12- TextMate
13- VSCode (default)
14
15These keymaps can be set via the `base_keymap` setting in your `keymap.json` file. Additionally, if you'd like to work from a clean slate, you can provide `"None"` to the setting.
16
17## Custom key bindings
18
19### Accessing custom key bindings
20
21You can open `keymap.json` via `โ` + `K`, `โ` + `S`, the command palette, or the `Zed > Settings > Open Key Bindings` application menu item.
22
23### Adding a custom key binding
24
25To customize key bindings, specify a context and the list of bindings to set. Re-mapping an existing binding will clobber the existing binding in favor of the custom one.
26
27An example of adding a set of custom key bindings:
28
29```json
30[
31 {
32 "context": "Editor",
33 "bindings": {
34 "ctrl-w": "editor::SelectLargerSyntaxNode",
35 "ctrl-shift-W": "editor::SelectSmallerSyntaxNode",
36 "ctrl-c": "editor::Cancel"
37 }
38 }
39]
40```
41
42You can see more examples in Zed's [`default.json`](https://github.com/zed-industries/zed/blob/main/assets/keymaps/default-macos.json)
43
44_There are some key bindings that can't be overridden; we are working on an issue surrounding this._
45
46### Keybinding syntax
47
48Zed has the ability to match against not just a single keypress, but a sequence of keys typed in order. Each key in the `"bindings"` map is a sequence of keypresses separated with a space.
49
50Each key press is a sequence of modifiers followed by a key. The modifiers are:
51
52- `ctrl-` The control key
53- `cmd-` On macOS, this is the command key
54- `alt-` On macOS, this is the option key
55- `shift-` The shift key
56- `fn-` The function key
57
58The keys can be any single unicode codepoint that your keyboard generates (for example `a`, `0`, `ยฃ` or `รง`).
59
60A few examples:
61
62```
63 "bindings": {
64 "cmd-k cmd-s": "zed::OpenKeyMap", // matches โ-k then โ-s
65 "space e": "editor::Complete", // type space then e
66 "รง": "editor::Complete", // matches โฅ-c
67 }
68```
69
70NOTE: Keys on a keyboard are not always the same as the character they generate. For example `shift-e` actually types `E` (or `alt-c` types `รง`). Zed allows you to match against either the key and its modifiers or the character it generates. This means you can specify `alt-c` or `รง`, but not `alt-รง`. It is usually better to specify the key and its modifiers, as this will work better on different keyboard layouts.
71
72### Remapping keys
73
74A common request is to be able to map from one sequence of keys to another. As of Zed 0.124.0 you can do this with the `workspace::SendKeystrokes` action.
75
76```json
77[
78 {
79 "bindings": {
80 "j k": ["workspace::SendKeystrokes", "escape"],
81 "alt-down": ["workspace::SendKeystrokes", "down down down down"],
82 "cmd-alt-c": [
83 "workspace::SendKeystrokes",
84 "cmd-shift-p copy relative path enter"
85 ],
86 "cmd-alt-r": ["workspace::SendKeystrokes", "cmd-p README enter"]
87 }
88 }
89]
90```
91
92There are some limitations to this, notably:
93
94- Any asynchronous operation will not happen until after all your key bindings have been dispatched. For example this means that while you can use a binding to open a file (as in the `cmd-alt-r` example) you cannot send further keystrokes and hope to have them interpreted by the new view.
95- - Other examples of asynchronous things are: communicating with a language server, changing the language of a buffer, anything that hits the network.
96- There is a limit of 100 simulated keys at a time, this is to avoid accidental infinite recursion if you trigger SendKeystrokes again inside your bindings.
97
98The argument to `SendKeystrokes` is a space-separated list of keystrokes (using the same syntax as above). Due to the way that keystrokes are parsed, any segment that is not recognized as a keypress will be sent verbatim to the currently focused input field.
99
100### All key bindings
101
102#### Global
103
104| **Command** | **Target** | **Default Shortcut** |
105| ------------------------- | ------------ | ----------------------- |
106| Toggle focus | Collab Panel | `โ + Shift + C` |
107| Toggle inlay hints | Editor | `Control + :` |
108| Cancel | Menu | `Control + C` |
109| Cancel | Menu | `Control + Escape` |
110| Cancel | Menu | `Escape` |
111| Cancel | Menu | `โ + Escape` |
112| Confirm | Menu | `Enter` |
113| Secondary confirm | Menu | `Control + Enter` |
114| Secondary confirm | Menu | `โ + Enter` |
115| Select first | Menu | `Page Up` |
116| Select first | Menu | `Shift + Page Down` |
117| Select first | Menu | `Shift + Page Up` |
118| Select first | Menu | `โ + Up` |
119| Select last | Menu | `Page Down` |
120| Select last | Menu | `โ + Down` |
121| Select next | Menu | `Control + N` |
122| Select next | Menu | `Down` |
123| Select prev | Menu | `Control + P` |
124| Select prev | Menu | `Up` |
125| Confirm input | Picker | `Alt + Enter` |
126| Confirm input | Picker | `โ + Alt + Enter` |
127| Use selected query | Picker | `Shift + Enter` |
128| Close window | Workspace | `โ + Shift + W` |
129| Follow next collaborator | Workspace | `Control + Alt + โ + F` |
130| Open | Workspace | `โ + O` |
131| Toggle zoom | Workspace | `Shift + Escape` |
132| Debug elements | Zed | `โ + Alt + I` |
133| Decrease buffer font size | Zed | `โ + ` |
134| Hide | Zed | `โ + H` |
135| Hide others | Zed | `Alt + โ + H` |
136| Increase buffer font size | Zed | `โ + +` |
137| Increase buffer font size | Zed | `โ + =` |
138| Minimize | Zed | `โ + M` |
139| Open settings | Zed | `โ + ,` |
140| Quit | Zed | `โ + Q` |
141| Reset buffer font size | Zed | `โ + 0` |
142| Toggle full screen | Zed | `Control + โ + F` |
143
144#### Editor
145
146| **Command** | **Target** | **Default Shortcut** |
147| -------------------------------- | ---------- | ------------------------------- |
148| Add selection above | Editor | `โ + Alt + Up` |
149| Add selection above | Editor | `โ + Control + P` |
150| Add selection below | Editor | `โ + Alt + Down` |
151| Add selection below | Editor | `โ + Control + N` |
152| Backspace | Editor | `Backspace` |
153| Backspace | Editor | `Control + H` |
154| Backspace | Editor | `Shift + Backspace` |
155| Cancel | Editor | `Escape` |
156| Confirm code action | Editor | `Enter` |
157| Confirm completion | Editor | `Enter` |
158| Confirm completion | Editor | `Tab` |
159| Confirm rename | Editor | `Enter` |
160| Context menu first | Editor | `Page Up` |
161| Context menu last | Editor | `Page Down` |
162| Context menu next | Editor | `Control + N` |
163| Context menu next | Editor | `Down` |
164| Context menu prev | Editor | `Control + P` |
165| Context menu prev | Editor | `Up` |
166| Copy | Editor | `โ + C` |
167| Cut | Editor | `โ + X` |
168| Cut to end of line | Editor | `Control + K` |
169| Delete | Editor | `Control + D` |
170| Delete | Editor | `Delete` |
171| Delete line | Editor | `โ + Shift + K` |
172| Delete to beginning of line | Editor | `โ + Backspace` |
173| Delete to end of line | Editor | `โ + Delete` |
174| Delete to next subword end | Editor | `Control + Alt + D` |
175| Delete to next subword end | Editor | `Control + Alt + Delete` |
176| Delete to next word end | Editor | `Alt + D` |
177| Delete to next word end | Editor | `Alt + Delete` |
178| Delete to previous subword start | Editor | `Control + Alt + Backspace` |
179| Delete to previous subword start | Editor | `Control + Alt + H` |
180| Delete to previous word start | Editor | `Alt + Backspace` |
181| Delete to previous word start | Editor | `Alt + H` |
182| Delete to previous word start | Editor | `Control + W` |
183| Display cursor names | Editor | `Control + โ + C` |
184| Duplicate line down | Editor | `Alt + Shift + Down` |
185| Duplicate line up | Editor | `Alt + Shift + Up` |
186| Find all references | Editor | `Alt + Shift + F12` |
187| Fold | Editor | `Alt + โ + [` |
188| Format | Editor | `โ + Shift + I` |
189| Go to definition | Editor | `F12` |
190| Go to definition split | Editor | `Alt + F12` |
191| Go to diagnostic | Editor | `F8` |
192| Go to implementation | Editor | `Shift + F12` |
193| Go to prev diagnostic | Editor | `Shift + F8` |
194| Go to type definition | Editor | `โ + F12` |
195| Go to type definition split | Editor | `Alt + โ + F12` |
196| Hover | Editor | `โ + K, โ + I` |
197| Indent | Editor | `โ + ]` |
198| Join lines | Editor | `Control + J` |
199| Move down | Editor | `Control + N` |
200| Move down | Editor | `Down` |
201| Move left | Editor | `Control + B` |
202| Move left | Editor | `Left` |
203| Move line down | Editor | `Alt + Down` |
204| Move line up | Editor | `Alt + Up` |
205| Move page down | Editor | `Control + V` |
206| Move page down | Editor | `Shift + Page Down` |
207| Move page up | Editor | `Alt + V` |
208| Move page up | Editor | `Shift + Page Up` |
209| Move right | Editor | `Control + F` |
210| Move right | Editor | `Right` |
211| Move to beginning | Editor | `โ + Up` |
212| Move to beginning of line | Editor | `Control + A` |
213| Move to beginning of line | Editor | `Home` |
214| Move to beginning of line | Editor | `โ + Left` |
215| Move to enclosing bracket | Editor | `Control + M` |
216| Move to end | Editor | `โ + Down` |
217| Move to end of line | Editor | `Control + E` |
218| Move to end of line | Editor | `End` |
219| Move to end of line | Editor | `โ + Right` |
220| Move to end of paragraph | Editor | `Control + Down` |
221| Move to next subword end | Editor | `Control + Alt + F` |
222| Move to next subword end | Editor | `Control + Alt + Right` |
223| Move to next word end | Editor | `Alt + F` |
224| Move to next word end | Editor | `Alt + Right` |
225| Move to previous subword start | Editor | `Control + Alt + B` |
226| Move to previous subword start | Editor | `Control + Alt + Left` |
227| Move to previous word start | Editor | `Alt + B` |
228| Move to previous word start | Editor | `Alt + Left` |
229| Move to start of paragraph | Editor | `Control + Up` |
230| Move up | Editor | `Control + P` |
231| Move up | Editor | `Up` |
232| Next screen | Editor | `Control + L` |
233| Outdent | Editor | `โ + [` |
234| Page down | Editor | `Page Down` |
235| Page up | Editor | `Page Up` |
236| Paste | Editor | `โ + V` |
237| Redo | Editor | `โ + Shift + Z` |
238| Redo selection | Editor | `โ + Shift + U` |
239| Rename | Editor | `F2` |
240| Reveal in finder | Editor | `Alt + โ + R` |
241| Revert selected hunks | Editor | `โ + Alt + Z` |
242| Select all | Editor | `โ + A` |
243| Select all matches | Editor | `โ + Shift + L` |
244| Select down | Editor | `Control + Shift + N` |
245| Select down | Editor | `Shift + Down` |
246| Select larger syntax node | Editor | `Control + Shift + Right` |
247| Select left | Editor | `Control + Shift + B` |
248| Select left | Editor | `Shift + Left` |
249| Select line | Editor | `โ + L` |
250| Select next | Editor | `โ + D` |
251| Select next | Editor | `โ + K, โ + D` |
252| Select previous | Editor | `Control + โ + D` |
253| Select previous | Editor | `โ + K, Control + โ + D` |
254| Select right | Editor | `Control + Shift + F` |
255| Select right | Editor | `Shift + Right` |
256| Select smaller syntax node | Editor | `Control + Shift + Left` |
257| Select to beginning | Editor | `โ + Shift + Up` |
258| Select to beginning of line | Editor | `Control + Shift + A` |
259| Select to beginning of line | Editor | `Shift + Home` |
260| Select to beginning of line | Editor | `โ + Shift + Left` |
261| Select to end | Editor | `โ + Shift + Down` |
262| Select to end of line | Editor | `Control + Shift + E` |
263| Select to end of line | Editor | `Shift + End` |
264| Select to end of line | Editor | `โ + Shift + Right` |
265| Select to end of paragraph | Editor | `Control + Shift + Down` |
266| Select to next subword end | Editor | `Control + Alt + Shift + F` |
267| Select to next subword end | Editor | `Control + Alt + Shift + Right` |
268| Select to next word end | Editor | `Alt + Shift + F` |
269| Select to next word end | Editor | `Alt + Shift + Right` |
270| Select to previous subword start | Editor | `Control + Alt + Shift + B` |
271| Select to previous subword start | Editor | `Control + Alt + Shift + Left` |
272| Select to previous word start | Editor | `Alt + Shift + B` |
273| Select to previous word start | Editor | `Alt + Shift + Left` |
274| Select to start of paragraph | Editor | `Control + Shift + Up` |
275| Select up | Editor | `Control + Shift + P` |
276| Select up | Editor | `Shift + Up` |
277| Show character palette | Editor | `Control + โ + Space` |
278| Show completions | Editor | `Control + Space` |
279| Show inline completion | Editor | `Alt + \` |
280| Tab | Editor | `Tab` |
281| Tab prev | Editor | `Shift + Tab` |
282| Toggle code actions | Editor | `โ + .` |
283| Toggle comments | Editor | `โ + /` |
284| Toggle git blame | Editor | `โ + Alt + G, B` |
285| Toggle line numbers | Editor | `โ + ;` |
286| Transpose | Editor | `Control + T` |
287| Undo | Editor | `โ + Z` |
288| Undo selection | Editor | `โ + U` |
289| Unfold lines | Editor | `Alt + โ + ]` |
290
291#### Editor (Full Only)
292
293| **Command** | **Target** | **Default Shortcut** |
294| -------------------------------- | ------------- | -------------------- |
295| Inline assist | Assistant | `Control + Enter` |
296| Quote selection | Assistant | `โ + >` |
297| Deploy | Buffer Search | `โ + Alt + F` |
298| Deploy | Buffer Search | `โ + E` |
299| Deploy | Buffer Search | `โ + F` |
300| Accept partial inline completion | Editor | `Alt + Right` |
301| Go to hunk | Editor | `โ + F8` |
302| Go to prev hunk | Editor | `โ + Shift + F8` |
303| Newline | Editor | `Enter` |
304| Newline | Editor | `Shift + Enter` |
305| Newline above | Editor | `โ + Shift + Enter` |
306| Newline below | Editor | `โ + Enter` |
307| Next inline completion | Editor | `Alt + ]` |
308| Open excerpts | Editor | `Alt + Enter` |
309| Open excerpts split | Editor | `โ + K, Enter` |
310| Previous inline completion | Editor | `Alt + [` |
311| Toggle soft wrap | Editor | `Alt + Z` |
312| Toggle | Go To Line | `Control + G` |
313| Toggle | Outline | `โ + Shift + O` |
314
315#### Editor (Auto Height Only)
316
317| **Command** | **Target** | **Default Shortcut** |
318| ------------- | ---------- | ------------------------- |
319| Newline | Editor | `Control + Enter` |
320| Newline | Editor | `Shift + Enter` |
321| Newline below | Editor | `Control + Shift + Enter` |
322
323#### Pane
324
325| **Command** | **Target** | **Default Shortcut** |
326| ----------------------------- | -------------- | ----------------------- |
327| Activate item 1 | Pane | `Control + 1` |
328| Activate item 2 | Pane | `Control + 2` |
329| Activate item 3 | Pane | `Control + 3` |
330| Activate item 4 | Pane | `Control + 4` |
331| Activate item 5 | Pane | `Control + 5` |
332| Activate item 6 | Pane | `Control + 6` |
333| Activate item 7 | Pane | `Control + 7` |
334| Activate item 8 | Pane | `Control + 8` |
335| Activate item 9 | Pane | `Control + 9` |
336| Activate last item | Pane | `Control + 0` |
337| Activate next item | Pane | `Alt + โ + Right` |
338| Activate next item | Pane | `โ + }` |
339| Activate prev item | Pane | `Alt + โ + Left` |
340| Activate prev item | Pane | `โ + {` |
341| Close active item | Pane | `โ + W` |
342| Close all items | Pane | `โ + K, โ + W` |
343| Close clean items | Pane | `โ + K, U` |
344| Close inactive items | Pane | `Alt + โ + T` |
345| Go back | Pane | `Control + ` |
346| Go forward | Pane | `Control + _` |
347| Reopen closed item | Pane | `โ + Shift + T` |
348| Split down | Pane | `โ + K, Down` |
349| Split left | Pane | `โ + K, Left` |
350| Split right | Pane | `โ + K, Right` |
351| Split up | Pane | `โ + K, Up` |
352| Toggle filters | Project Search | `Alt + โ + F` |
353| Toggle focus | Project Search | `โ + F` |
354| Toggle focus | Project Search | `โ + Shift + F` |
355| Activate regex mode | Search | `Alt + โ + G` |
356| Activate text mode | Search | `Alt + โ + X` |
357| Cycle mode | Search | `Alt + Tab` |
358| Select all matches | Search | `Alt + Enter` |
359| Select next match | Search | `โ + G` |
360| Select prev match | Search | `โ + Shift + G` |
361| Toggle case sensitive | Search | `Alt + โ + C` |
362| Toggle replace | Search | `โ + Shift + H` |
363| Toggle whole word | Search | `Alt + โ + W` |
364| Close inactive tabs and panes | Workspace | `Control + Alt + โ + W` |
365
366#### Buffer Search Bar
367
368| **Command** | **Target** | **Default Shortcut** |
369| ---------------------- | ------------- | -------------------- |
370| Dismiss | Buffer Search | `Escape` |
371| Focus editor | Buffer Search | `Tab` |
372| Cycle mode | Search | `Alt + Tab` |
373| Focus search | Search | `โ + F` |
374| Next history query | Search | `Down` |
375| Previous history query | Search | `Up` |
376| Replace all | Search | `โ + Enter` |
377| Replace next | Search | `Enter` |
378| Select all matches | Search | `Alt + Enter` |
379| Select next match | Search | `Enter` |
380| Select prev match | Search | `Shift + Enter` |
381| Toggle replace | Search | `โ + Alt + F` |
382
383#### Workspace
384
385| **Command** | **Target** | **Default Shortcut** |
386| -------------------------------- | ----------------- | ----------------------- |
387| Toggle focus | Assistant | `โ + ?` |
388| Open recent | Branches | `Alt + โ + B` |
389| Toggle | Command Palette | `โ + Shift + P` |
390| Deploy | Diagnostics | `โ + Shift + M` |
391| Toggle | File Finder | `โ + P` |
392| Toggle | Language Selector | `โ + K, M` |
393| Deploy search | Pane | `โ + Shift + F` |
394| Deploy search | Pane | `โ + Shift + H` |
395| Toggle focus | Project Panel | `โ + Shift + E` |
396| Toggle | Project Symbols | `โ + T` |
397| Open recent | Projects | `Alt + โ + O` |
398| Toggle | Tab Switcher | `Control + Shift + Tab` |
399| Toggle | Tab Switcher | `Control + Tab` |
400| Rerun | Task | `Alt + T` |
401| Spawn | Task | `Alt + Shift + T` |
402| Toggle focus | Terminal Panel | ``Control + ` `` |
403| Toggle | Theme Selector | `โ + K, โ + T` |
404| Activate pane 1 | Workspace | `โ + 1` |
405| Activate pane 2 | Workspace | `โ + 2` |
406| Activate pane 3 | Workspace | `โ + 3` |
407| Activate pane 4 | Workspace | `โ + 4` |
408| Activate pane 5 | Workspace | `โ + 5` |
409| Activate pane 6 | Workspace | `โ + 6` |
410| Activate pane 7 | Workspace | `โ + 7` |
411| Activate pane 8 | Workspace | `โ + 8` |
412| Activate pane 9 | Workspace | `โ + 9` |
413| Activate pane in direction down | Workspace | `โ + K, โ + Down` |
414| Activate pane in direction left | Workspace | `โ + K, โ + Left` |
415| Activate pane in direction right | Workspace | `โ + K, โ + Right` |
416| Activate pane in direction up | Workspace | `โ + K, โ + Up` |
417| Close all docks | Workspace | `Alt + โ + Y` |
418| New file | Workspace | `โ + N` |
419| New terminal | Workspace | `Control + ~` |
420| New window | Workspace | `โ + Shift + N` |
421| Save | Workspace | `โ + S` |
422| Save all | Workspace | `โ + Alt + S` |
423| Save as | Workspace | `โ + Shift + S` |
424| Save without format | Workspace | `โ + K, S` |
425| Swap pane in direction | Workspace | `โ + K, Shift + Down` |
426| Swap pane in direction | Workspace | `โ + K, Shift + Left` |
427| Swap pane in direction | Workspace | `โ + K, Shift + Right` |
428| Swap pane in direction | Workspace | `โ + K, Shift + Up` |
429| Toggle bottom dock | Workspace | `โ + J` |
430| Toggle left dock | Workspace | `โ + B` |
431| Toggle right dock | Workspace | `โ + R` |
432| Unfollow | Workspace | `Escape` |
433| Open keymap | Zed | `โ + K, โ + S` |
434
435#### Project Panel
436
437| **Command** | **Target** | **Default Shortcut** |
438| ----------------------- | ------------- | --------------------- |
439| Collapse selected entry | Project Panel | `Left` |
440| Copy | Project Panel | `โ + C` |
441| Copy path | Project Panel | `โ + Alt + C` |
442| Copy relative path | Project Panel | `Alt + โ + Shift + C` |
443| Cut | Project Panel | `โ + X` |
444| Delete | Project Panel | `Backspace` |
445| Delete | Project Panel | `Delete` |
446| Delete | Project Panel | `โ + Backspace` |
447| Delete | Project Panel | `โ + Delete` |
448| Expand selected entry | Project Panel | `Right` |
449| New directory | Project Panel | `Alt + โ + N` |
450| New file | Project Panel | `โ + N` |
451| New search in directory | Project Panel | `Alt + Shift + F` |
452| Open | Project Panel | `Space` |
453| Paste | Project Panel | `โ + V` |
454| Rename | Project Panel | `Enter` |
455| Rename | Project Panel | `F2` |
456| Reveal in finder | Project Panel | `Alt + โ + R` |
457
458#### Project Search Bar
459
460| **Command** | **Target** | **Default Shortcut** |
461| ---------------------- | -------------- | -------------------- |
462| Search in new | Project Search | `โ + Enter` |
463| Toggle focus | Project Search | `Escape` |
464| Activate regex mode | Search | `Alt + โ + G` |
465| Activate text mode | Search | `Alt + โ + X` |
466| Cycle mode | Search | `Alt + Tab` |
467| Focus search | Search | `โ + Shift + F` |
468| Next history query | Search | `Down` |
469| Previous history query | Search | `Up` |
470| Replace all | Search | `โ + Enter` |
471| Replace next | Search | `Enter` |
472| Toggle replace | Search | `โ + Shift + H` |
473
474#### Terminal
475
476| **Command** | **Target** | **Default Shortcut** |
477| --------------------------- | ---------- | --------------------- |
478| Clear | Terminal | `โ + K` |
479| Copy | Terminal | `โ + C` |
480| Delete line | Terminal | `โ + Backspace` |
481| Move to beginning of line | Terminal | `โ + Left` |
482| Move to end of line | Terminal | `โ + Right` |
483| Move to next word end | Terminal | `Alt + Right` |
484| Move to previous word start | Terminal | `Alt + Left` |
485| Paste | Terminal | `โ + V` |
486| Show character palette | Terminal | `Control + โ + Space` |
487
488#### Assistant Editor
489
490| **Command** | **Target** | **Default Shortcut** |
491| ------------------ | ---------- | -------------------- |
492| Assist | Assistant | `โ + Enter` |
493| Cycle message role | Assistant | `Control + R` |
494| Quote selection | Assistant | `โ + >` |
495| Split | Assistant | `Shift + Enter` |
496| Save | Workspace | `โ + S` |