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