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