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-space": "editor::SetMark", // set-mark
19 "ctrl-@": "editor::SetMark", // set-mark
20 "ctrl-x ctrl-x": "editor::SwapSelectionEnds", // exchange-point-and-mark
21 "ctrl-f": "editor::MoveRight", // forward-char
22 "ctrl-b": "editor::MoveLeft", // backward-char
23 "ctrl-n": "editor::MoveDown", // next-line
24 "ctrl-p": "editor::MoveUp", // previous-line
25 "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
26 "end": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
27 "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
28 "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
29 "shift-home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
30 "shift-end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
31 "alt-m": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false, "stop_at_indent": true }], // back-to-indentation
32 "alt-f": "editor::MoveToNextSubwordEnd", // forward-word
33 "alt-b": "editor::MoveToPreviousSubwordStart", // backward-word
34 "alt-u": "editor::ConvertToUpperCase", // upcase-word
35 "alt-l": "editor::ConvertToLowerCase", // downcase-word
36 "alt-c": "editor::ConvertToUpperCamelCase", // capitalize-word
37 "ctrl-t": "editor::Transpose", // transpose-chars
38 "alt-;": ["editor::ToggleComments", { "advance_downwards": false }],
39 "ctrl-x ctrl-;": "editor::ToggleComments",
40 "alt-.": "editor::GoToDefinition", // xref-find-definitions
41 "alt-?": "editor::FindAllReferences", // xref-find-references
42 "alt-,": "pane::GoBack", // xref-pop-marker-stack
43 "ctrl-x h": "editor::SelectAll", // mark-whole-buffer
44 "ctrl-d": "editor::Delete", // delete-char
45 "alt-d": ["editor::DeleteToNextWordEnd", { "ignore_newlines": false, "ignore_brackets": false }], // kill-word
46 "ctrl-k": "editor::KillRingCut", // kill-line
47 "ctrl-w": "editor::Cut", // kill-region
48 "alt-w": "editor::Copy", // kill-ring-save
49 "ctrl-y": "editor::KillRingYank", // yank
50 "ctrl-_": "editor::Undo", // undo
51 "ctrl-/": "editor::Undo", // undo
52 "ctrl-x u": "editor::Undo", // undo
53 "alt-{": "editor::MoveToStartOfParagraph", // backward-paragraph
54 "alt-}": "editor::MoveToEndOfParagraph", // forward-paragraph
55 "ctrl-v": "editor::MovePageDown", // scroll-up
56 "alt-v": "editor::MovePageUp", // scroll-down
57 "ctrl-x [": "editor::MoveToBeginning", // beginning-of-buffer
58 "ctrl-x ]": "editor::MoveToEnd", // end-of-buffer
59 "alt-<": "editor::MoveToBeginning", // beginning-of-buffer
60 "alt->": "editor::MoveToEnd", // end-of-buffer
61 "ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
62 "ctrl-s": "buffer_search::Deploy", // isearch-forward
63 "alt-^": "editor::JoinLines", // join-line
64 "alt-q": "editor::Rewrap" // fill-paragraph
65 }
66 },
67 {
68 "context": "Editor && selection_mode", // region selection
69 "bindings": {
70 "right": "editor::SelectRight",
71 "left": "editor::SelectLeft",
72 "down": "editor::SelectDown",
73 "up": "editor::SelectUp",
74 "alt-left": "editor::SelectToPreviousWordStart",
75 "alt-right": "editor::SelectToNextWordEnd",
76 "pagedown": "editor::SelectPageDown",
77 "ctrl-v": "editor::SelectPageDown",
78 "pageup": "editor::SelectPageUp",
79 "alt-v": "editor::SelectPageUp",
80 "ctrl-f": "editor::SelectRight",
81 "ctrl-b": "editor::SelectLeft",
82 "ctrl-n": "editor::SelectDown",
83 "ctrl-p": "editor::SelectUp",
84 "home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
85 "end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
86 "ctrl-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
87 "ctrl-e": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
88 "alt-f": "editor::SelectToNextWordEnd",
89 "alt-b": "editor::SelectToPreviousSubwordStart",
90 "alt-<": "editor::SelectToBeginning",
91 "alt->": "editor::SelectToEnd",
92 "ctrl-g": "editor::Cancel"
93 }
94 },
95 {
96 "context": "Editor && (showing_code_actions || showing_completions)",
97 "bindings": {
98 "ctrl-p": "editor::ContextMenuPrevious",
99 "ctrl-n": "editor::ContextMenuNext"
100 }
101 },
102 {
103 "context": "Editor && showing_signature_help && !showing_completions",
104 "bindings": {
105 "ctrl-p": "editor::SignatureHelpPrevious",
106 "ctrl-n": "editor::SignatureHelpNext"
107 }
108 },
109 {
110 "context": "Workspace",
111 "bindings": {
112 "ctrl-x ctrl-c": "zed::Quit", // save-buffers-kill-terminal
113 "ctrl-x 5 0": "workspace::CloseWindow", // delete-frame
114 "ctrl-x 5 2": "workspace::NewWindow", // make-frame-command
115 "ctrl-x o": "workspace::ActivateNextPane", // other-window
116 "ctrl-x k": "pane::CloseActiveItem", // kill-buffer
117 "ctrl-x 0": "pane::CloseActiveItem", // delete-window
118 "ctrl-x 1": "pane::CloseOtherItems", // delete-other-windows
119 "ctrl-x 2": "pane::SplitDown", // split-window-below
120 "ctrl-x 3": "pane::SplitRight", // split-window-right
121 "ctrl-x ctrl-f": "file_finder::Toggle", // find-file
122 "ctrl-x ctrl-s": "workspace::Save", // save-buffer
123 "ctrl-x ctrl-w": "workspace::SaveAs", // write-file
124 "ctrl-x s": "workspace::SaveAll" // save-some-buffers
125 }
126 },
127 {
128 // Workaround to enable using emacs in the Zed terminal.
129 // Unbind so Zed ignores these keys and lets emacs handle them.
130 "context": "Terminal",
131 "bindings": {
132 "ctrl-x ctrl-c": null, // save-buffers-kill-terminal
133 "ctrl-x ctrl-f": null, // find-file
134 "ctrl-x ctrl-s": null, // save-buffer
135 "ctrl-x ctrl-w": null, // write-file
136 "ctrl-x s": null // save-some-buffers
137 }
138 },
139 {
140 "context": "BufferSearchBar > Editor",
141 "bindings": {
142 "ctrl-s": "search::SelectNextMatch",
143 "ctrl-r": "search::SelectPreviousMatch",
144 "ctrl-g": "buffer_search::Dismiss"
145 }
146 },
147 {
148 "context": "Pane",
149 "bindings": {
150 "ctrl-alt-left": "pane::GoBack",
151 "ctrl-alt-right": "pane::GoForward"
152 }
153 }
154]