emacs.json

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