Key bindings

Zed can be configured via a simple JSON file located at ~/.config/zed/keymap.json.

Predefined keymaps

We have a growing collection of pre-defined keymaps in zed repository's keymaps folder. Our current keymaps include:

  • Atom
  • JetBrains
  • SublimeText
  • TextMate
  • VSCode (default)

These keymaps can be set via the base_keymap setting in your settings.json file. Additionally, if you'd like to work from a clean slate, you can provide "None" to the setting.

Custom key bindings

Accessing custom key bindings

You can open keymap.json via + K, + S, the command palette, or the Zed > Settings > Open Key Bindings application menu item.

Adding a custom key binding

To customize key bindings, specify a context and the list of bindings to set. Re-mapping an existing binding will clobber the existing binding in favor of the custom one.

An example of adding a set of custom key bindings:

[
  {
    "context": "Editor",
    "bindings": {
      "ctrl-w": "editor::SelectLargerSyntaxNode",
      "ctrl-shift-W": "editor::SelectSmallerSyntaxNode",
      "ctrl-c": "editor::Cancel"
    }
  }
]

You can see more examples in Zed's default.json

There are some key bindings that can't be overridden; we are working on an issue surrounding this.

Keybinding syntax

Zed has the ability to match against not just a single keypress, but a sequence of keys typed in order. Each key in the "bindings" map is a sequence of keypresses separated with a space.

Each key press is a sequence of modifiers followed by a key. The modifiers are:

  • ctrl- The control key
  • cmd-, win- or super- for the platform modifier (Command on macOS, Windows key on Windows, and the Super key on Linux).
  • alt- for alt (option on macOS)
  • shift- The shift key
  • fn- The function key

The keys can be any single unicode codepoint that your keyboard generates (for example a, 0, £ or ç), or any named key (tab, f1, shift, or cmd).

A few examples:

 "bindings": {
   "cmd-k cmd-s": "zed::OpenKeymap", // matches ⌘-k then ⌘-s
   "space e": "editor::Complete", // type space then e
   "ç": "editor::Complete", // matches ⌥-c
   "shift shift": "file_finder::Toggle", // matches pressing and releasing shift twice
 }

The shift- modifier can only be used in combination with a letter to indicate the uppercase version. For example shift-g matches typing G. Although on many keyboards shift is used to type punctuation characters like (, the keypress is not considered to be modified and so shift-( does not match.

The alt- modifier can be used on many layouts to generate a different key. For example on macOS US keyboard the combination alt-c types ç. You can match against either in your keymap file, though by convention Zed spells this combination as alt-c.

It is possible to match against typing a modifier key on its own. For example shift shift can be used to implement JetBrains search everywhere shortcut. In this case the binding happens on key release instead of key press.

Remapping keys

A common request is to be able to map from one sequence of keys to another. As of Zed 0.124.0 you can do this with the workspace::SendKeystrokes action.

[
  {
    "bindings": {
      "alt-down": ["workspace::SendKeystrokes", "down down down down"],
      "cmd-alt-c": [
        "workspace::SendKeystrokes",
        "cmd-shift-p copy relative path enter"
      ],
      "cmd-alt-r": ["workspace::SendKeystrokes", "cmd-p README enter"]
    }
  },
  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      "j k": ["workspace::SendKeystrokes", "escape"]
    }
  }
]

There are some limitations to this, notably:

  • Any asynchronous operation will not happen until after all your key bindings have been dispatched. For example this means that while you can use a binding to open a file (as in the cmd-alt-r example) you cannot send further keystrokes and hope to have them interpreted by the new view.
    • Other examples of asynchronous things are: communicating with a language server, changing the language of a buffer, anything that hits the network.
  • There is a limit of 100 simulated keys at a time, this is to avoid accidental infinite recursion if you trigger SendKeystrokes again inside your bindings.

The argument to SendKeystrokes is a space-separated list of keystrokes (using the same syntax as above). Due to the way that keystrokes are parsed, any segment that is not recognized as a keypress will be sent verbatim to the currently focused input field.

Forward keys to terminal

If you're on Linux or Windows, you might find yourself wanting to forward key combinations to the built-in terminal instead of them being handled by Zed.

For example, ctrl-n creates a new tab in Zed on Linux. If you want to send ctrl-n to the built-in terminal when it's focused, add the following to your keymap:

{
  "context": "Terminal",
  "bindings": {
    "ctrl-n": ["terminal::SendKeystroke", "ctrl-n"]
  }
}

Task Key bindings

You can also bind keys to launch Zed Tasks defined in your tasks.json. See the tasks documentation for more.

All key bindings

Global

CommandTargetDefault Shortcut
Toggle focusCollab Panel⌘ + Shift + C
Toggle inlay hintsEditorControl + :
CancelMenuControl + C
CancelMenuControl + Escape
CancelMenuEscape
CancelMenu⌘ + Escape
ConfirmMenuEnter
Secondary confirmMenuControl + Enter
Secondary confirmMenu⌘ + Enter
Select firstMenuPage Up
Select firstMenuShift + Page Down
Select firstMenuShift + Page Up
Select firstMenu⌘ + Up
Select lastMenuPage Down
Select lastMenu⌘ + Down
Select nextMenuControl + N
Select nextMenuDown
Select prevMenuControl + P
Select prevMenuUp
Confirm inputPickerAlt + Enter
Confirm inputPicker⌘ + Alt + Enter
Use selected queryPickerShift + Enter
Close windowWorkspace⌘ + Shift + W
Follow next collaboratorWorkspaceControl + Alt + ⌘ + F
OpenWorkspace⌘ + O
Toggle zoomWorkspaceShift + Escape
Debug elementsZed⌘ + Alt + I
Decrease buffer font sizeZed⌘ + -
HideZed⌘ + H
Hide othersZedAlt + ⌘ + H
Increase buffer font sizeZed⌘ + +
Increase buffer font sizeZed⌘ + =
MinimizeZed⌘ + M
Open settingsZed⌘ + ,
QuitZed⌘ + Q
Reset buffer font sizeZed⌘ + 0
Toggle full screenZedControl + ⌘ + F

Editor

CommandTargetDefault Shortcut
Add selection aboveEditor⌘ + Alt + Up
Add selection aboveEditor⌘ + Control + P
Add selection belowEditor⌘ + Alt + Down
Add selection belowEditor⌘ + Control + N
BackspaceEditorBackspace
BackspaceEditorControl + H
BackspaceEditorShift + Backspace
CancelEditorEscape
Confirm code actionEditorEnter
Confirm completionEditorEnter
Confirm completionEditorTab
Confirm renameEditorEnter
Context menu firstEditorPage Up
Context menu lastEditorPage Down
Context menu nextEditorControl + N
Context menu nextEditorDown
Context menu prevEditorControl + P
Context menu prevEditorUp
CopyEditor⌘ + C
CutEditor⌘ + X
Cut to end of lineEditorControl + K
DeleteEditorControl + D
DeleteEditorDelete
Delete lineEditor⌘ + Shift + K
Delete to beginning of lineEditor⌘ + Backspace
Delete to end of lineEditor⌘ + Delete
Delete to next subword endEditorControl + Alt + D
Delete to next subword endEditorControl + Alt + Delete
Delete to next word endEditorAlt + D
Delete to next word endEditorAlt + Delete
Delete to previous subword startEditorControl + Alt + Backspace
Delete to previous subword startEditorControl + Alt + H
Delete to previous word startEditorAlt + Backspace
Delete to previous word startEditorAlt + H
Delete to previous word startEditorControl + W
Display cursor namesEditorControl + ⌘ + C
Duplicate line downEditorAlt + Shift + Down
Duplicate line upEditorAlt + Shift + Up
Find all referencesEditorAlt + Shift + F12
FoldEditorAlt + ⌘ + [
FormatEditor⌘ + Shift + I
Go to definitionEditorF12
Go to definition splitEditorAlt + F12
Go to diagnosticEditorF8
Go to implementationEditorShift + F12
Go to prev diagnosticEditorShift + F8
Go to type definitionEditor⌘ + F12
Go to type definition splitEditorAlt + ⌘ + F12
HoverEditor⌘ + K, ⌘ + I
IndentEditor⌘ + ]
Join linesEditorControl + J
Move downEditorControl + N
Move downEditorDown
Move leftEditorControl + B
Move leftEditorLeft
Move line downEditorAlt + Down
Move line upEditorAlt + Up
Move page downEditorControl + V
Move page downEditorShift + Page Down
Move page upEditorAlt + V
Move page upEditorShift + Page Up
Move rightEditorControl + F
Move rightEditorRight
Move to beginningEditor⌘ + Up
Move to beginning of lineEditorControl + A
Move to beginning of lineEditorHome
Move to beginning of lineEditor⌘ + Left
Move to enclosing bracketEditorControl + M
Move to endEditor⌘ + Down
Move to end of lineEditorControl + E
Move to end of lineEditorEnd
Move to end of lineEditor⌘ + Right
Move to end of paragraphEditorControl + Down
Move to next subword endEditorControl + Alt + F
Move to next subword endEditorControl + Alt + Right
Move to next word endEditorAlt + F
Move to next word endEditorAlt + Right
Move to previous subword startEditorControl + Alt + B
Move to previous subword startEditorControl + Alt + Left
Move to previous word startEditorAlt + B
Move to previous word startEditorAlt + Left
Move to start of paragraphEditorControl + Up
Move upEditorControl + P
Move upEditorUp
Next screenEditorControl + L
OutdentEditor⌘ + [
Page downEditorPage Down
Page upEditorPage Up
PasteEditor⌘ + V
RedoEditor⌘ + Shift + Z
Redo selectionEditor⌘ + Shift + U
RenameEditorF2
Reveal in File ManagerEditorAlt + ⌘ + R
Toggle hunk diffEditor⌘ + '
Expand all hunk diffsEditor⌘ + "
Revert selected hunksEditor⌘ + Alt + Z
Select allEditor⌘ + A
Select all matchesEditor⌘ + Shift + L
Select downEditorControl + Shift + N
Select downEditorShift + Down
Select larger syntax nodeEditorControl + Shift + Right
Select leftEditorControl + Shift + B
Select leftEditorShift + Left
Select lineEditor⌘ + L
Select nextEditor⌘ + D
Select nextEditor⌘ + K, ⌘ + D
Select previousEditorControl + ⌘ + D
Select previousEditor⌘ + K, Control + ⌘ + D
Select rightEditorControl + Shift + F
Select rightEditorShift + Right
Select smaller syntax nodeEditorControl + Shift + Left
Select to beginningEditor⌘ + Shift + Up
Select to beginning of lineEditorControl + Shift + A
Select to beginning of lineEditorShift + Home
Select to beginning of lineEditor⌘ + Shift + Left
Select to endEditor⌘ + Shift + Down
Select to end of lineEditorControl + Shift + E
Select to end of lineEditorShift + End
Select to end of lineEditor⌘ + Shift + Right
Select to end of paragraphEditorControl + Shift + Down
Select to next subword endEditorControl + Alt + Shift + F
Select to next subword endEditorControl + Alt + Shift + Right
Select to next word endEditorAlt + Shift + F
Select to next word endEditorAlt + Shift + Right
Select to previous subword startEditorControl + Alt + Shift + B
Select to previous subword startEditorControl + Alt + Shift + Left
Select to previous word startEditorAlt + Shift + B
Select to previous word startEditorAlt + Shift + Left
Select to start of paragraphEditorControl + Shift + Up
Select upEditorControl + Shift + P
Select upEditorShift + Up
Show character paletteEditorControl + ⌘ + Space
Show completionsEditorControl + Space
Show inline completionEditorAlt + \
TabEditorTab
Tab prevEditorShift + Tab
Toggle code actionsEditor⌘ + .
Toggle commentsEditor⌘ + /
Toggle git blameEditor⌘ + Alt + G, B
Toggle line numbersEditor⌘ + ;
TransposeEditorControl + T
UndoEditor⌘ + Z
Undo selectionEditor⌘ + U
Unfold linesEditorAlt + ⌘ + ]

Editor (Full Only)

CommandTargetDefault Shortcut
Inline assistAssistantControl + Enter
Quote selectionAssistant⌘ + >
DeployBuffer Search⌘ + Alt + F
DeployBuffer Search⌘ + E
DeployBuffer Search⌘ + F
Accept partial inline completionEditorAlt + Right
Go to hunkEditor⌘ + F8
Go to prev hunkEditor⌘ + Shift + F8
NewlineEditorEnter
NewlineEditorShift + Enter
Newline aboveEditor⌘ + Shift + Enter
Newline belowEditor⌘ + Enter
Next inline completionEditorAlt + ]
Open excerptsEditorAlt + Enter
Open excerpts splitEditor⌘ + K, Enter
Previous inline completionEditorAlt + [
Toggle soft wrapEditorAlt + Z
ToggleGo To LineControl + G
ToggleOutline⌘ + Shift + O

Editor (Auto Height Only)

CommandTargetDefault Shortcut
NewlineEditorControl + Enter
NewlineEditorShift + Enter
Newline belowEditorControl + Shift + Enter

Pane

CommandTargetDefault Shortcut
Activate item 1PaneControl + 1
Activate item 2PaneControl + 2
Activate item 3PaneControl + 3
Activate item 4PaneControl + 4
Activate item 5PaneControl + 5
Activate item 6PaneControl + 6
Activate item 7PaneControl + 7
Activate item 8PaneControl + 8
Activate item 9PaneControl + 9
Activate last itemPaneControl + 0
Activate next itemPaneAlt + ⌘ + Right
Activate next itemPane⌘ + }
Activate prev itemPaneAlt + ⌘ + Left
Activate prev itemPane⌘ + {
Close active itemPane⌘ + W
Close all itemsPane⌘ + K, ⌘ + W
Close clean itemsPane⌘ + K, U
Close inactive itemsPaneAlt + ⌘ + T
Go backPaneControl + -
Go forwardPaneControl + _
Reopen closed itemPane⌘ + Shift + T
Split downPane⌘ + K, Down
Split leftPane⌘ + K, Left
Split rightPane⌘ + K, Right
Split upPane⌘ + K, Up
Toggle filtersProject SearchAlt + ⌘ + F
Toggle focusProject Search⌘ + F
Toggle focusProject Search⌘ + Shift + F
Activate regex modeSearchAlt + ⌘ + G
Activate text modeSearchAlt + ⌘ + X
Cycle modeSearchAlt + Tab
Select all matchesSearchAlt + Enter
Select next matchSearch⌘ + G
Select prev matchSearch⌘ + Shift + G
Toggle case sensitiveSearchAlt + ⌘ + C
Toggle replaceSearch⌘ + Shift + H
Toggle whole wordSearchAlt + ⌘ + W
Close inactive tabs and panesWorkspaceControl + Alt + ⌘ + W
CommandTargetDefault Shortcut
DismissBuffer SearchEscape
Focus editorBuffer SearchTab
Cycle modeSearchAlt + Tab
Focus searchSearch⌘ + F
Next history querySearchDown
Previous history querySearchUp
Replace allSearch⌘ + Enter
Replace nextSearchEnter
Select all matchesSearchAlt + Enter
Select next matchSearchEnter
Select prev matchSearchShift + Enter
Toggle replaceSearch⌘ + Alt + F

Workspace

CommandTargetDefault Shortcut
Toggle focusAssistant⌘ + ?
Open recentBranchesAlt + ⌘ + B
ToggleCommand Palette⌘ + Shift + P
DeployDiagnostics⌘ + Shift + M
ToggleFile Finder⌘ + P
ToggleLanguage Selector⌘ + K, M
Deploy searchPane⌘ + Shift + F
Deploy searchPane⌘ + Shift + H
Toggle focusProject Panel⌘ + Shift + E
ToggleProject Symbols⌘ + T
Open recentProjectsAlt + ⌘ + O
ToggleTab SwitcherControl + Shift + Tab
ToggleTab SwitcherControl + Tab
RerunTaskAlt + T
SpawnTaskAlt + Shift + T
Toggle focusTerminal PanelControl + `
ToggleTheme Selector⌘ + K, ⌘ + T
Activate pane 1Workspace⌘ + 1
Activate pane 2Workspace⌘ + 2
Activate pane 3Workspace⌘ + 3
Activate pane 4Workspace⌘ + 4
Activate pane 5Workspace⌘ + 5
Activate pane 6Workspace⌘ + 6
Activate pane 7Workspace⌘ + 7
Activate pane 8Workspace⌘ + 8
Activate pane 9Workspace⌘ + 9
Activate pane in direction downWorkspace⌘ + K, ⌘ + Down
Activate pane in direction leftWorkspace⌘ + K, ⌘ + Left
Activate pane in direction rightWorkspace⌘ + K, ⌘ + Right
Activate pane in direction upWorkspace⌘ + K, ⌘ + Up
Close all docksWorkspaceAlt + ⌘ + Y
New fileWorkspace⌘ + N
New terminalWorkspaceControl + ~
New windowWorkspace⌘ + Shift + N
SaveWorkspace⌘ + S
Save allWorkspace⌘ + Alt + S
Save asWorkspace⌘ + Shift + S
Save without formatWorkspace⌘ + K, S
Swap pane in directionWorkspace⌘ + K, Shift + Down
Swap pane in directionWorkspace⌘ + K, Shift + Left
Swap pane in directionWorkspace⌘ + K, Shift + Right
Swap pane in directionWorkspace⌘ + K, Shift + Up
Toggle bottom dockWorkspace⌘ + J
Toggle left dockWorkspace⌘ + B
Toggle right dockWorkspace⌘ + R
UnfollowWorkspaceEscape
Open keymapZed⌘ + K, ⌘ + S

Project Panel

CommandTargetDefault Shortcut
Collapse selected entryProject PanelLeft
CopyProject Panel⌘ + C
Copy pathProject Panel⌘ + Alt + C
Copy relative pathProject PanelAlt + ⌘ + Shift + C
CutProject Panel⌘ + X
DeleteProject PanelBackspace
DeleteProject PanelDelete
DeleteProject Panel⌘ + Backspace
DeleteProject Panel⌘ + Delete
Expand selected entryProject PanelRight
New directoryProject PanelAlt + ⌘ + N
New fileProject Panel⌘ + N
New search in directoryProject PanelAlt + Shift + F
OpenProject PanelSpace
PasteProject Panel⌘ + V
RenameProject PanelEnter
RenameProject PanelF2
Reveal in File ManagerProject PanelAlt + ⌘ + R
CommandTargetDefault Shortcut
Search in newProject Search⌘ + Enter
Toggle focusProject SearchEscape
Activate regex modeSearchAlt + ⌘ + G
Activate text modeSearchAlt + ⌘ + X
Cycle modeSearchAlt + Tab
Focus searchSearch⌘ + Shift + F
Next history querySearchDown
Previous history querySearchUp
Replace allSearch⌘ + Enter
Replace nextSearchEnter
Toggle replaceSearch⌘ + Shift + H

Terminal

CommandTargetDefault Shortcut
ClearTerminal⌘ + K
CopyTerminal⌘ + C
Delete lineTerminal⌘ + Backspace
Move to beginning of lineTerminal⌘ + Left
Move to end of lineTerminal⌘ + Right
Move to next word endTerminalAlt + Right
Move to previous word startTerminalAlt + Left
PasteTerminal⌘ + V
Show character paletteTerminalControl + ⌘ + Space

Assistant Editor

CommandTargetDefault Shortcut
AssistAssistant⌘ + Enter
Cycle message roleAssistantControl + R
Quote selectionAssistant⌘ + >
SplitAssistantShift + Enter
SaveWorkspace⌘ + S