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-,": "pane::GoBack", // xref-pop-marker-stack
42 "ctrl-x h": "editor::SelectAll", // mark-whole-buffer
43 "ctrl-d": "editor::Delete", // delete-char
44 "alt-d": "editor::DeleteToNextWordEnd", // kill-word
45 "ctrl-k": "editor::KillRingCut", // kill-line
46 "ctrl-w": "editor::Cut", // kill-region
47 "alt-w": "editor::Copy", // kill-ring-save
48 "ctrl-y": "editor::KillRingYank", // yank
49 "ctrl-_": "editor::Undo", // undo
50 "ctrl-/": "editor::Undo", // undo
51 "ctrl-x u": "editor::Undo", // undo
52 "alt-{": "editor::MoveToStartOfParagraph", // backward-paragraph
53 "alt-}": "editor::MoveToEndOfParagraph", // forward-paragraph
54 "ctrl-v": "editor::MovePageDown", // scroll-up
55 "alt-v": "editor::MovePageUp", // scroll-down
56 "ctrl-x [": "editor::MoveToBeginning", // beginning-of-buffer
57 "ctrl-x ]": "editor::MoveToEnd", // end-of-buffer
58 "alt-<": "editor::MoveToBeginning", // beginning-of-buffer
59 "alt->": "editor::MoveToEnd", // end-of-buffer
60 "ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
61 "ctrl-s": "buffer_search::Deploy", // isearch-forward
62 "alt-^": "editor::JoinLines", // join-line
63 "alt-q": "editor::Rewrap" // fill-paragraph
64 }
65 },
66 {
67 "context": "Editor && selection_mode", // region selection
68 "bindings": {
69 "right": "editor::SelectRight",
70 "left": "editor::SelectLeft",
71 "down": "editor::SelectDown",
72 "up": "editor::SelectUp",
73 "alt-left": "editor::SelectToPreviousWordStart",
74 "alt-right": "editor::SelectToNextWordEnd",
75 "pagedown": "editor::SelectPageDown",
76 "ctrl-v": "editor::SelectPageDown",
77 "pageup": "editor::SelectPageUp",
78 "alt-v": "editor::SelectPageUp",
79 "ctrl-f": "editor::SelectRight",
80 "ctrl-b": "editor::SelectLeft",
81 "ctrl-n": "editor::SelectDown",
82 "ctrl-p": "editor::SelectUp",
83 "home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
84 "end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
85 "ctrl-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
86 "ctrl-e": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
87 "alt-f": "editor::SelectToNextWordEnd",
88 "alt-b": "editor::SelectToPreviousSubwordStart",
89 "alt-<": "editor::SelectToBeginning",
90 "alt->": "editor::SelectToEnd",
91 "ctrl-g": "editor::Cancel"
92 }
93 },
94 {
95 "context": "Editor && (showing_code_actions || showing_completions)",
96 "bindings": {
97 "ctrl-p": "editor::ContextMenuPrevious",
98 "ctrl-n": "editor::ContextMenuNext"
99 }
100 },
101 {
102 "context": "Workspace",
103 "bindings": {
104 "ctrl-x ctrl-c": "zed::Quit", // save-buffers-kill-terminal
105 "ctrl-x 5 0": "workspace::CloseWindow", // delete-frame
106 "ctrl-x 5 2": "workspace::NewWindow", // make-frame-command
107 "ctrl-x o": "workspace::ActivateNextPane", // other-window
108 "ctrl-x k": "pane::CloseActiveItem", // kill-buffer
109 "ctrl-x 0": "pane::CloseActiveItem", // delete-window
110 "ctrl-x 1": "pane::CloseInactiveItems", // delete-other-windows
111 "ctrl-x 2": "pane::SplitDown", // split-window-below
112 "ctrl-x 3": "pane::SplitRight", // split-window-right
113 "ctrl-x ctrl-f": "file_finder::Toggle", // find-file
114 "ctrl-x ctrl-s": "workspace::Save", // save-buffer
115 "ctrl-x ctrl-w": "workspace::SaveAs", // write-file
116 "ctrl-x s": "workspace::SaveAll" // save-some-buffers
117 }
118 },
119 {
120 // Workaround to enable using emacs in the Zed terminal.
121 // Unbind so Zed ignores these keys and lets emacs handle them.
122 "context": "Terminal",
123 "bindings": {
124 "ctrl-x ctrl-c": null, // save-buffers-kill-terminal
125 "ctrl-x ctrl-f": null, // find-file
126 "ctrl-x ctrl-s": null, // save-buffer
127 "ctrl-x ctrl-w": null, // write-file
128 "ctrl-x s": null // save-some-buffers
129 }
130 },
131 {
132 "context": "BufferSearchBar > Editor",
133 "bindings": {
134 "ctrl-s": "search::SelectNextMatch",
135 "ctrl-r": "search::SelectPreviousMatch",
136 "ctrl-g": "buffer_search::Dismiss"
137 }
138 },
139 {
140 "context": "Pane",
141 "bindings": {
142 "ctrl-alt-left": "pane::GoBack",
143 "ctrl-alt-right": "pane::GoForward"
144 }
145 }
146]