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",
19 "ctrl-f": "editor::MoveRight", // forward-char
20 "ctrl-b": "editor::MoveLeft", // backward-char
21 "ctrl-n": "editor::MoveDown", // next-line
22 "ctrl-p": "editor::MoveUp", // previous-line
23 "home": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
24 "end": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
25 "ctrl-a": ["editor::MoveToBeginningOfLine", { "stop_at_soft_wraps": false }], // move-beginning-of-line
26 "ctrl-e": ["editor::MoveToEndOfLine", { "stop_at_soft_wraps": false }], // move-end-of-line
27 "alt-f": "editor::MoveToNextSubwordEnd", // forward-word
28 "alt-b": "editor::MoveToPreviousSubwordStart", // backward-word
29 "alt-u": "editor::ConvertToUpperCase", // upcase-word
30 "alt-l": "editor::ConvertToLowerCase", // downcase-word
31 "alt-c": "editor::ConvertToUpperCamelCase", // capitalize-word
32 "ctrl-t": "editor::Transpose", // transpose-chars
33 "alt-;": ["editor::ToggleComments", { "advance_downwards": false }],
34 "ctrl-x ctrl-;": "editor::ToggleComments",
35 "alt-.": "editor::GoToDefinition", // xref-find-definitions
36 "alt-,": "pane::GoBack", // xref-pop-marker-stack
37 "ctrl-x h": "editor::SelectAll", // mark-whole-buffer
38 "ctrl-d": "editor::Delete", // delete-char
39 "alt-d": "editor::DeleteToNextWordEnd", // kill-word
40 "ctrl-k": "editor::KillRingCut", // kill-line
41 "ctrl-w": "editor::Cut", // kill-region
42 "alt-w": "editor::Copy", // kill-ring-save
43 "ctrl-y": "editor::KillRingYank", // yank
44 "ctrl-_": "editor::Undo", // undo
45 "ctrl-/": "editor::Undo", // undo
46 "ctrl-x u": "editor::Undo", // undo
47 "ctrl-v": "editor::MovePageDown", // scroll-up
48 "alt-v": "editor::MovePageUp", // scroll-down
49 "ctrl-x [": "editor::MoveToBeginning", // beginning-of-buffer
50 "ctrl-x ]": "editor::MoveToEnd", // end-of-buffer
51 "alt-<": "editor::MoveToBeginning", // beginning-of-buffer
52 "alt->": "editor::MoveToEnd", // end-of-buffer
53 "ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
54 "ctrl-s": "buffer_search::Deploy", // isearch-forward
55 "alt-^": "editor::JoinLines" // join-line
56 }
57 },
58 {
59 "context": "Workspace",
60 "bindings": {
61 "ctrl-x ctrl-c": "zed::Quit", // save-buffers-kill-terminal
62 "ctrl-x 5 0": "workspace::CloseWindow", // delete-frame
63 "ctrl-x 5 2": "workspace::NewWindow", // make-frame-command
64 "ctrl-x o": "workspace::ActivateNextPane", // other-window
65 "ctrl-x k": "pane::CloseActiveItem", // kill-buffer
66 "ctrl-x 0": "pane::CloseActiveItem", // delete-window
67 "ctrl-x 1": "pane::CloseInactiveItems", // delete-other-windows
68 "ctrl-x 2": "pane::SplitDown", // split-window-below
69 "ctrl-x 3": "pane::SplitRight", // split-window-right
70 "ctrl-x ctrl-f": "file_finder::Toggle", // find-file
71 "ctrl-x ctrl-s": "workspace::Save", // save-buffer
72 "ctrl-x ctrl-w": "workspace::SaveAs", // write-file
73 "ctrl-x s": "workspace::SaveAll" // save-some-buffers
74 }
75 },
76 {
77 // Workaround to enable using emacs in the Zed terminal.
78 // Unbind so Zed ignores these keys and lets emacs handle them.
79 "context": "Terminal",
80 "bindings": {
81 "ctrl-x ctrl-c": null, // save-buffers-kill-terminal
82 "ctrl-x ctrl-f": null, // find-file
83 "ctrl-x ctrl-s": null, // save-buffer
84 "ctrl-x ctrl-w": null, // write-file
85 "ctrl-x s": null // save-some-buffers
86 }
87 },
88 {
89 "context": "BufferSearchBar > Editor",
90 "bindings": {
91 "ctrl-s": "search::SelectNextMatch",
92 "ctrl-r": "search::SelectPrevMatch",
93 "ctrl-g": "buffer_search::Dismiss"
94 }
95 },
96 {
97 "context": "Pane",
98 "bindings": {
99 "ctrl-alt-left": "pane::GoBack",
100 "ctrl-alt-right": "pane::GoForward"
101 }
102 }
103]