1// documentation: https://zed.dev/docs/key-bindings
2//
3// To see the default key bindings run `zed: open default keymap`
4// from the command palette.
5[
6 {
7 "bindings": {
8 "ctrl-g": "menu::Cancel"
9 }
10 },
11 {
12 "context": "Editor",
13 "bindings": {
14 "ctrl-g": "editor::Cancel",
15 "ctrl-x b": "tab_switcher::Toggle", // switch-to-buffer
16 "alt-g g": "go_to_line::Toggle", // goto-line
17 "alt-g alt-g": "go_to_line::Toggle", // goto-line
18 "ctrl-f": "editor::MoveRight", // forward-char
19 "ctrl-b": "editor::MoveLeft", // backward-char
20 "ctrl-n": "editor::MoveDown", // next-line
21 "ctrl-p": "editor::MoveUp", // previous-line
22 "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
23 "end": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
24 "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
25 "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
26 "alt-f": "editor::MoveToNextSubwordEnd", // forward-word
27 "alt-b": "editor::MoveToPreviousSubwordStart", // backward-word
28 "alt-u": "editor::ConvertToUpperCase", // upcase-word
29 "alt-l": "editor::ConvertToLowerCase", // downcase-word
30 "alt-c": "editor::ConvertToUpperCamelCase", // capitalize-word
31 "ctrl-t": "editor::Transpose", // transpose-chars
32 "alt-;": ["editor::ToggleComments", { "advance_downwards": false }],
33 "ctrl-x ctrl-;": "editor::ToggleComments",
34 "alt-.": "editor::GoToDefinition", // xref-find-definitions
35 "alt-,": "pane::GoBack", // xref-pop-marker-stack
36 "ctrl-x h": "editor::SelectAll", // mark-whole-buffer
37 "ctrl-d": "editor::Delete", // delete-char
38 "alt-d": "editor::DeleteToNextWordEnd", // kill-word
39 "ctrl-k": "editor::KillRingCut", // kill-line
40 "ctrl-w": "editor::Cut", // kill-region
41 "alt-w": "editor::Copy", // kill-ring-save
42 "ctrl-y": "editor::KillRingYank", // yank
43 "ctrl-_": "editor::Undo", // undo
44 "ctrl-/": "editor::Undo", // undo
45 "ctrl-x u": "editor::Undo", // undo
46 "ctrl-v": "editor::MovePageDown", // scroll-up
47 "alt-v": "editor::MovePageUp", // scroll-down
48 "ctrl-x [": "editor::MoveToBeginning", // beginning-of-buffer
49 "ctrl-x ]": "editor::MoveToEnd", // end-of-buffer
50 "alt-<": "editor::MoveToBeginning", // beginning-of-buffer
51 "alt->": "editor::MoveToEnd", // end-of-buffer
52 "ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
53 "ctrl-s": "buffer_search::Deploy", // isearch-forward
54 "alt-^": "editor::JoinLines", // join-line
55 "alt-/": "editor::ShowCompletions" // dabbrev-expand
56 }
57 },
58 // Extend selection with movement bindings
59 {
60 "context": "Editor && (mode == full) && selection",
61 "bindings": {
62 "right": "editor::SelectRight",
63 "left": "editor::SelectLeft",
64 "down": "editor::SelectDown",
65 "up": "editor::SelectUp",
66 "home": "editor::SelectToBeginningOfLine",
67 "end": "editor::SelectToEndOfLine",
68 "alt-left": "editor::SelectToPreviousWordStart",
69 "alt-right": "editor::SelectToNextWordEnd",
70 "pagedown": "editor::SelectPageDown",
71 "pageup": "editor::SelectPageUp",
72 "ctrl-f": "editor::SelectRight",
73 "ctrl-b": "editor::SelectLeft",
74 "ctrl-n": "editor::SelectDown",
75 "ctrl-p": "editor::SelectUp",
76 "ctrl-a": "editor::SelectToBeginningOfLine",
77 "ctrl-e": "editor::SelectToEndOfLine",
78 "alt-f": "editor::SelectToNextWordEnd",
79 "alt-b": "editor::SelectToPreviousSubwordStart",
80 "alt-<": "editor::SelectToBeginning",
81 "alt->": "editor::SelectToEnd",
82 "ctrl-space": "editor::Cancel" // clear mark
83 }
84 },
85 // Emacs set-mark-command emulation (ctrl-space + movement bindings)
86 {
87 "context": "Editor && (mode == full) && !selection",
88 "bindings": {
89 "ctrl-space right": "editor::SelectRight",
90 "ctrl-space left": "editor::SelectLeft",
91 "ctrl-space down": "editor::SelectDown",
92 "ctrl-space up": "editor::SelectUp",
93 "ctrl-space home": "editor::SelectToBeginningOfLine",
94 "ctrl-space end": "editor::SelectToEndOfLine",
95 "ctrl-space alt-left": "editor::SelectToPreviousWordStart",
96 "ctrl-space alt-right": "editor::SelectToNextWordEnd",
97 "ctrl-space pagedown": "editor::SelectPageDown",
98 "ctrl-space pageup": "editor::SelectPageUp",
99 "ctrl-space ctrl-f": "editor::SelectRight",
100 "ctrl-space ctrl-b": "editor::SelectLeft",
101 "ctrl-space ctrl-n": "editor::SelectDown",
102 "ctrl-space ctrl-p": "editor::SelectUp",
103 "ctrl-space ctrl-a": "editor::SelectToBeginningOfLine",
104 "ctrl-space ctrl-e": "editor::SelectToEndOfLine",
105 "ctrl-space alt-f": "editor::SelectToNextWordEnd",
106 "ctrl-space alt-b": "editor::SelectToPreviousWordStart",
107 "ctrl-space alt-<": "editor::SelectToBeginning",
108 "ctrl-space alt->": "editor::SelectToEnd",
109 "ctrl-space alt-v": "editor::SelectPageUp",
110 "ctrl-space ctrl-v": "editor::SelectPageDown",
111 "ctrl-space alt-{": "editor::SelectToStartOfParagraph",
112 "ctrl-space alt-}": "editor::SelectToEndOfParagraph"
113 }
114 },
115 {
116 "context": "Workspace",
117 "bindings": {
118 "ctrl-x ctrl-c": "zed::Quit", // save-buffers-kill-terminal
119 "ctrl-x 5 0": "workspace::CloseWindow", // delete-frame
120 "ctrl-x 5 2": "workspace::NewWindow", // make-frame-command
121 "ctrl-x o": "workspace::ActivateNextPane", // other-window
122 "ctrl-x k": "pane::CloseActiveItem", // kill-buffer
123 "ctrl-x 0": "pane::CloseActiveItem", // delete-window
124 "ctrl-x 1": "pane::CloseInactiveItems", // delete-other-windows
125 "ctrl-x 2": "pane::SplitDown", // split-window-below
126 "ctrl-x 3": "pane::SplitRight", // split-window-right
127 "ctrl-x ctrl-f": "file_finder::Toggle", // find-file
128 "ctrl-x ctrl-s": "workspace::Save", // save-buffer
129 "ctrl-x ctrl-w": "workspace::SaveAs", // write-file
130 "ctrl-x s": "workspace::SaveAll" // save-some-buffers
131 }
132 },
133 {
134 // Workaround to enable using emacs in the Zed terminal.
135 // Unbind so Zed ignores these keys and lets emacs handle them.
136 "context": "Terminal",
137 "bindings": {
138 "ctrl-x ctrl-c": null, // save-buffers-kill-terminal
139 "ctrl-x ctrl-f": null, // find-file
140 "ctrl-x ctrl-s": null, // save-buffer
141 "ctrl-x ctrl-w": null, // write-file
142 "ctrl-x s": null // save-some-buffers
143 }
144 },
145 {
146 "context": "BufferSearchBar > Editor",
147 "bindings": {
148 "ctrl-s": "search::SelectNextMatch",
149 "ctrl-r": "search::SelectPrevMatch",
150 "ctrl-g": "buffer_search::Dismiss"
151 }
152 },
153 {
154 "context": "Pane",
155 "bindings": {
156 "ctrl-alt-left": "pane::GoBack",
157 "ctrl-alt-right": "pane::GoForward"
158 }
159 }
160]