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 }
64 },
65 {
66 "context": "Editor && selection_mode", // region selection
67 "bindings": {
68 "right": "editor::SelectRight",
69 "left": "editor::SelectLeft",
70 "down": "editor::SelectDown",
71 "up": "editor::SelectUp",
72 "alt-left": "editor::SelectToPreviousWordStart",
73 "alt-right": "editor::SelectToNextWordEnd",
74 "pagedown": "editor::SelectPageDown",
75 "ctrl-v": "editor::SelectPageDown",
76 "pageup": "editor::SelectPageUp",
77 "alt-v": "editor::SelectPageUp",
78 "ctrl-f": "editor::SelectRight",
79 "ctrl-b": "editor::SelectLeft",
80 "ctrl-n": "editor::SelectDown",
81 "ctrl-p": "editor::SelectUp",
82 "home": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
83 "end": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
84 "ctrl-a": ["editor::SelectToBeginningOfLine", { "stop_at_soft_wraps": false }],
85 "ctrl-e": ["editor::SelectToEndOfLine", { "stop_at_soft_wraps": false }],
86 "alt-f": "editor::SelectToNextWordEnd",
87 "alt-b": "editor::SelectToPreviousSubwordStart",
88 "alt-<": "editor::SelectToBeginning",
89 "alt->": "editor::SelectToEnd",
90 "ctrl-g": "editor::Cancel"
91 }
92 },
93 {
94 "context": "Workspace",
95 "bindings": {
96 "ctrl-x ctrl-c": "zed::Quit", // save-buffers-kill-terminal
97 "ctrl-x 5 0": "workspace::CloseWindow", // delete-frame
98 "ctrl-x 5 2": "workspace::NewWindow", // make-frame-command
99 "ctrl-x o": "workspace::ActivateNextPane", // other-window
100 "ctrl-x k": "pane::CloseActiveItem", // kill-buffer
101 "ctrl-x 0": "pane::CloseActiveItem", // delete-window
102 "ctrl-x 1": "pane::CloseInactiveItems", // delete-other-windows
103 "ctrl-x 2": "pane::SplitDown", // split-window-below
104 "ctrl-x 3": "pane::SplitRight", // split-window-right
105 "ctrl-x ctrl-f": "file_finder::Toggle", // find-file
106 "ctrl-x ctrl-s": "workspace::Save", // save-buffer
107 "ctrl-x ctrl-w": "workspace::SaveAs", // write-file
108 "ctrl-x s": "workspace::SaveAll" // save-some-buffers
109 }
110 },
111 {
112 // Workaround to enable using emacs in the Zed terminal.
113 // Unbind so Zed ignores these keys and lets emacs handle them.
114 "context": "Terminal",
115 "bindings": {
116 "ctrl-x ctrl-c": null, // save-buffers-kill-terminal
117 "ctrl-x ctrl-f": null, // find-file
118 "ctrl-x ctrl-s": null, // save-buffer
119 "ctrl-x ctrl-w": null, // write-file
120 "ctrl-x s": null // save-some-buffers
121 }
122 },
123 {
124 "context": "BufferSearchBar > Editor",
125 "bindings": {
126 "ctrl-s": "search::SelectNextMatch",
127 "ctrl-r": "search::SelectPreviousMatch",
128 "ctrl-g": "buffer_search::Dismiss"
129 }
130 },
131 {
132 "context": "Pane",
133 "bindings": {
134 "ctrl-alt-left": "pane::GoBack",
135 "ctrl-alt-right": "pane::GoForward"
136 }
137 }
138]