Configuring Zed with Emacs Keybindings | Generated by AI

Home 2025.10

Configuring Zed Editor with Emacs Keybindings

It looks like you might mean Zed (the high-performance code editor), as “Zig editor” doesn’t refer to a standard tool—Zig is a programming language without a built-in editor. If that’s not what you intended, feel free to clarify! Assuming Zed, it has built-in support for Emacs keybindings (labeled “Emacs (Beta)”). This covers many basics out of the box, like movement (Ctrl-b/f/n/p) and editing (Ctrl-d for delete char, Ctrl-k for cut to end of line). You can enable it easily, then customize further if needed.

Step 1: Enable the Built-in Emacs Keymap

Zed’s Emacs mode is predefined and doesn’t require manual binding setup for basics. Here’s how to switch to it:

  1. Open Zed’s settings:
    • macOS: Cmd-,
    • Windows/Linux: Ctrl-,
  2. In the settings UI, search for “base keymap” and set it to Emacs.

    Or, edit directly in settings.json (open via Cmd-Alt-, on macOS or Ctrl-Alt-, on Windows/Linux):

    {
      "base_keymap": "Emacs"
    }
    

    Save and reload Zed (Cmd-R or Ctrl-R). That’s it—the beta Emacs keymap activates immediately.

    Alternatively, use the command palette (Cmd-Shift-P or Ctrl-Shift-P), type “toggle base keymap,” and select Emacs.

This gives you core Emacs muscle memory without extra work. For a full list of built-in bindings, check Zed’s default keymap files in the source (e.g., via GitHub), but basics include:

Step 2: Add or Customize Basic Bindings (If Needed)

For tweaks or more Emacs-like behavior (e.g., better home/end or paragraph nav), edit keymap.json:

Add bindings as a JSON array under contexts like “Editor.” Here’s a minimal example for basic movement and editing (paste into the array; it’s based on community configs for compatibility):

[
  {
    "context": "Editor",
    "bindings": {
      // Basic movement
      "ctrl-a": "editor::MoveToBeginningOfLine",
      "ctrl-e": "editor::MoveToEndOfLine",
      "ctrl-b": "editor::MoveLeft",
      "ctrl-f": "editor::MoveRight",
      "ctrl-p": "editor::MoveLineUp",
      "ctrl-n": "editor::MoveLineDown",
      "alt-b": "editor::MoveToPreviousWordStart",
      "alt-f": "editor::MoveToNextWordEnd",

      // Basic editing
      "ctrl-d": "editor::DeleteRight",
      "ctrl-k": "editor::CutToEndOfLine",
      "ctrl-y": "editor::Paste",
      "ctrl-w": "editor::Cut",
      "ctrl-@": ["editor::SetSelectionAnchor", { "selection_id": 0 }],  // Set mark
      "ctrl-x ctrl-x": "editor::FlipSelectionAnchor",  // Exchange point/mark

      // Navigation extras
      "ctrl-home": "editor::MoveToBeginning",
      "ctrl-end": "editor::MoveToEnd",
      "ctrl-g": "editor::Cancel"
    }
  }
]

Tips

This should get you 80% of basic Emacs feel. Start with the built-in, then iterate!

Key Bindings Docs
Configuring Zed
Emacs Keymap Discussion
Emacs Compatibility Issue


Back

x-ai/grok-4-fast

Donate