key-bindings.md

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.

Disabling a key binding

Use null value to disable a key binding:

[
  {
    "context": "Editor",
    "bindings": {
      "alt-\\": null
    }
  }
]

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.

Contexts

Each key binding includes a context which determes when the key binding is active. If no context key is present it is considered to be in the Global context. The context is a boolean expression that can include the following:

  • Pane
  • Workspace
  • Editor
  • Menu
  • Terminal
  • Assistant
  • ProjectPanel
  • ProjectSearch
  • BufferSearch
  • Search
  • Dock
  • EmptyPane
  • SharedScreen
  • VimControl
  • vim_mode == normal
  • vim_mode == visual
  • vim_mode == insert
  • vim_mode == replace
  • vim_mode == operator
  • vim_mode == waiting

See also: vim context docs

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

Command Target Default Shortcut
Toggle focus Collab Panel โŒ˜ + Shift + C
Toggle inlay hints Editor Control + :
Cancel Menu Control + C
Cancel Menu Control + Escape
Cancel Menu Escape
Cancel Menu โŒ˜ + Escape
Confirm Menu Enter
Secondary confirm Menu Control + Enter
Secondary confirm Menu โŒ˜ + Enter
Select first Menu Page Up
Select first Menu Shift + Page Down
Select first Menu Shift + Page Up
Select first Menu โŒ˜ + Up
Select last Menu Page Down
Select last Menu โŒ˜ + Down
Select next Menu Control + N
Select next Menu Down
Select prev Menu Control + P
Select prev Menu Up
Confirm input Picker Alt + Enter
Confirm input Picker โŒ˜ + Alt + Enter
Use selected query Picker Shift + Enter
Close window Workspace โŒ˜ + Shift + W
Follow next collaborator Workspace Control + Alt + โŒ˜ + F
Open Workspace โŒ˜ + O
Toggle zoom Workspace Shift + Escape
Debug elements Zed โŒ˜ + Alt + I
Decrease buffer font size Zed โŒ˜ + -
Hide Zed โŒ˜ + H
Hide others Zed Alt + โŒ˜ + H
Increase buffer font size Zed โŒ˜ + +
Increase buffer font size Zed โŒ˜ + =
Minimize Zed โŒ˜ + M
Open settings Zed โŒ˜ + ,
Quit Zed โŒ˜ + Q
Reset buffer font size Zed โŒ˜ + 0
Toggle full screen Zed Control + โŒ˜ + F

Editor

Command Target Default Shortcut
Add selection above Editor โŒ˜ + Alt + Up
Add selection above Editor โŒ˜ + Control + P
Add selection below Editor โŒ˜ + Alt + Down
Add selection below Editor โŒ˜ + Control + N
Backspace Editor Backspace
Backspace Editor Control + H
Backspace Editor Shift + Backspace
Cancel Editor Escape
Confirm code action Editor Enter
Confirm completion Editor Enter
Confirm completion Editor Tab
Confirm rename Editor Enter
Context menu first Editor Page Up
Context menu last Editor Page Down
Context menu next Editor Control + N
Context menu next Editor Down
Context menu prev Editor Control + P
Context menu prev Editor Up
Copy Editor โŒ˜ + C
Cut Editor โŒ˜ + X
Cut to end of line Editor Control + K
Select Next Editor Control + D
Delete Editor Delete
Delete line Editor โŒ˜ + Shift + K
Delete to beginning of line Editor โŒ˜ + Backspace
Delete to end of line Editor โŒ˜ + Delete
Delete to next subword end Editor Control + Alt + D
Delete to next subword end Editor Control + Alt + Delete
Delete to next word end Editor Alt + D
Delete to next word end Editor Alt + Delete
Delete to previous subword start Editor Control + Alt + Backspace
Delete to previous subword start Editor Control + Alt + H
Delete to previous word start Editor Alt + Backspace
Delete to previous word start Editor Alt + H
Delete to previous word start Editor Control + W
Display cursor names Editor Control + โŒ˜ + C
Duplicate line down Editor Alt + Shift + Down
Duplicate line up Editor Alt + Shift + Up
Find all references Editor Alt + Shift + F12
Fold Editor Alt + โŒ˜ + [
Format Editor โŒ˜ + Shift + I
Go to definition Editor F12
Go to definition split Editor Alt + F12
Go to declaration Editor Ctrl + F12
Go to declaration split Editor Alt + Ctrl + F12
Go to diagnostic Editor F8
Go to implementation Editor Shift + F12
Go to prev diagnostic Editor Shift + F8
Go to type definition Editor โŒ˜ + F12
Go to type definition split Editor Alt + โŒ˜ + F12
Hover Editor โŒ˜ + K, โŒ˜ + I
Indent Editor โŒ˜ + ]
Join lines Editor Control + J
Move down Editor Control + N
Move down Editor Down
Move left Editor Control + B
Move left Editor Left
Move line down Editor Alt + Down
Move line up Editor Alt + Up
Move page down Editor Control + V
Move page down Editor Shift + Page Down
Move page up Editor Alt + V
Move page up Editor Shift + Page Up
Move right Editor Control + F
Move right Editor Right
Move to beginning Editor โŒ˜ + Up
Move to beginning of line Editor Control + A
Move to beginning of line Editor Home
Move to beginning of line Editor โŒ˜ + Left
Move to enclosing bracket Editor Control + M
Move to end Editor โŒ˜ + Down
Move to end of line Editor Control + E
Move to end of line Editor End
Move to end of line Editor โŒ˜ + Right
Move to end of paragraph Editor Control + Down
Move to next subword end Editor Control + Alt + F
Move to next subword end Editor Control + Alt + Right
Move to next word end Editor Alt + F
Move to next word end Editor Alt + Right
Move to previous subword start Editor Control + Alt + B
Move to previous subword start Editor Control + Alt + Left
Move to previous word start Editor Alt + B
Move to previous word start Editor Alt + Left
Move to start of paragraph Editor Control + Up
Move up Editor Control + P
Move up Editor Up
Next screen Editor Control + L
Outdent Editor โŒ˜ + [
Page down Editor Page Down
Page up Editor Page Up
Paste Editor โŒ˜ + V
Redo Editor โŒ˜ + Shift + Z
Redo selection Editor โŒ˜ + Shift + U
Rename Editor F2
Reveal in File Manager Editor Alt + โŒ˜ + R
Toggle hunk diff Editor โŒ˜ + '
Expand all hunk diffs Editor โŒ˜ + "
Revert selected hunks Editor โŒ˜ + Alt + Z
Select all Editor โŒ˜ + A
Select all matches Editor โŒ˜ + Shift + L
Select down Editor Control + Shift + N
Select down Editor Shift + Down
Select larger syntax node Editor Control + Shift + Right
Select left Editor Control + Shift + B
Select left Editor Shift + Left
Select line Editor โŒ˜ + L
Select next Editor โŒ˜ + D
Select next Editor โŒ˜ + K, โŒ˜ + D
Select previous Editor Control + โŒ˜ + D
Select previous Editor โŒ˜ + K, Control + โŒ˜ + D
Select right Editor Control + Shift + F
Select right Editor Shift + Right
Select smaller syntax node Editor Control + Shift + Left
Select to beginning Editor โŒ˜ + Shift + Up
Select to beginning of line Editor Control + Shift + A
Select to beginning of line Editor Shift + Home
Select to beginning of line Editor โŒ˜ + Shift + Left
Select to end Editor โŒ˜ + Shift + Down
Select to end of line Editor Control + Shift + E
Select to end of line Editor Shift + End
Select to end of line Editor โŒ˜ + Shift + Right
Select to end of paragraph Editor Control + Shift + Down
Select to next subword end Editor Control + Alt + Shift + F
Select to next subword end Editor Control + Alt + Shift + Right
Select to next word end Editor Alt + Shift + F
Select to next word end Editor Alt + Shift + Right
Select to previous subword start Editor Control + Alt + Shift + B
Select to previous subword start Editor Control + Alt + Shift + Left
Select to previous word start Editor Alt + Shift + B
Select to previous word start Editor Alt + Shift + Left
Select to start of paragraph Editor Control + Shift + Up
Select up Editor Control + Shift + P
Select up Editor Shift + Up
Show character palette Editor Control + โŒ˜ + Space
Show completions Editor Control + Space
Show inline completion Editor Alt + \
Tab Editor Tab
Tab prev Editor Shift + Tab
Toggle code actions Editor โŒ˜ + .
Toggle comments Editor โŒ˜ + /
Toggle git blame Editor โŒ˜ + Alt + G, B
Toggle line numbers Editor โŒ˜ + ;
Transpose Editor Control + T
Undo Editor โŒ˜ + Z
Undo selection Editor โŒ˜ + U
Unfold lines Editor Alt + โŒ˜ + ]

Editor (Full Only)

Command Target Default Shortcut
Inline assist Assistant Control + Enter
Quote selection Assistant โŒ˜ + >
Deploy Buffer Search โŒ˜ + Alt + F
Deploy Buffer Search โŒ˜ + E
Deploy Buffer Search โŒ˜ + F
Accept partial inline completion Editor Alt + Right
Go to hunk Editor โŒ˜ + F8
Go to prev hunk Editor โŒ˜ + Shift + F8
Newline Editor Enter
Newline Editor Shift + Enter
Newline above Editor โŒ˜ + Shift + Enter
Newline below Editor โŒ˜ + Enter
Next inline completion Editor Alt + ]
Open excerpts Editor Alt + Enter
Open excerpts split Editor โŒ˜ + K, Enter
Previous inline completion Editor Alt + [
Toggle soft wrap Editor Alt + Z
Toggle Go To Line Control + G
Toggle Outline โŒ˜ + Shift + O

Editor (Auto Height Only)

Command Target Default Shortcut
Newline Editor Control + Enter
Newline Editor Shift + Enter
Newline below Editor Control + Shift + Enter

Pane

Command Target Default Shortcut
Activate item 1 Pane Control + 1
Activate item 2 Pane Control + 2
Activate item 3 Pane Control + 3
Activate item 4 Pane Control + 4
Activate item 5 Pane Control + 5
Activate item 6 Pane Control + 6
Activate item 7 Pane Control + 7
Activate item 8 Pane Control + 8
Activate item 9 Pane Control + 9
Activate last item Pane Control + 0
Activate next item Pane Alt + โŒ˜ + Right
Activate next item Pane โŒ˜ + }
Activate prev item Pane Alt + โŒ˜ + Left
Activate prev item Pane โŒ˜ + {
Swap item to left Pane Control + Shift + Page Up
Swap item to right Pane Control + Shift + Page Down
Close active item Pane โŒ˜ + W
Close all items Pane โŒ˜ + K, โŒ˜ + W
Close clean items Pane โŒ˜ + K, U
Close inactive items Pane Alt + โŒ˜ + T
Go back Pane Control + -
Go forward Pane Control + Shift + _
Reopen closed item Pane โŒ˜ + Shift + T
Split down Pane โŒ˜ + K, Down
Split left Pane โŒ˜ + K, Left
Split right Pane โŒ˜ + K, Right
Split up Pane โŒ˜ + K, Up
Toggle filters Project Search Alt + โŒ˜ + F
Toggle focus Project Search โŒ˜ + F
Toggle focus Project Search โŒ˜ + Shift + F
Activate regex mode Search Alt + โŒ˜ + G
Activate text mode Search Alt + โŒ˜ + X
Cycle mode Search Alt + Tab
Select all matches Search Alt + Enter
Select next match Search โŒ˜ + G
Select prev match Search โŒ˜ + Shift + G
Toggle case sensitive Search Alt + โŒ˜ + C
Toggle replace Search โŒ˜ + Shift + H
Toggle whole word Search Alt + โŒ˜ + W
Close inactive tabs and panes Workspace Control + Alt + โŒ˜ + W
Command Target Default Shortcut
Dismiss Buffer Search Escape
Focus editor Buffer Search Tab
Cycle mode Search Alt + Tab
Focus search Search โŒ˜ + F
Next history query Search Down
Previous history query Search Up
Replace all Search โŒ˜ + Enter
Replace next Search Enter
Select all matches Search Alt + Enter
Select next match Search Enter
Select prev match Search Shift + Enter
Toggle replace Search โŒ˜ + Alt + F

Workspace

Command Target Default Shortcut
Toggle focus Assistant โŒ˜ + ?
Open recent Branches Alt + โŒ˜ + B
Toggle Command Palette โŒ˜ + Shift + P
Deploy Diagnostics โŒ˜ + Shift + M
Toggle File Finder โŒ˜ + P
Toggle Language Selector โŒ˜ + K, M
Deploy search Pane โŒ˜ + Shift + F
Deploy search Pane โŒ˜ + Shift + H
Toggle focus Project Panel โŒ˜ + Shift + E
Toggle Project Symbols โŒ˜ + T
Open recent Projects Alt + โŒ˜ + O
Toggle Tab Switcher Control + Shift + Tab
Toggle Tab Switcher Control + Tab
Rerun Task Alt + T
Spawn Task Alt + Shift + T
Toggle focus Terminal Panel Control + `
Toggle Theme Selector โŒ˜ + K, โŒ˜ + T
Activate pane 1 Workspace โŒ˜ + 1
Activate pane 2 Workspace โŒ˜ + 2
Activate pane 3 Workspace โŒ˜ + 3
Activate pane 4 Workspace โŒ˜ + 4
Activate pane 5 Workspace โŒ˜ + 5
Activate pane 6 Workspace โŒ˜ + 6
Activate pane 7 Workspace โŒ˜ + 7
Activate pane 8 Workspace โŒ˜ + 8
Activate pane 9 Workspace โŒ˜ + 9
Activate pane in direction down Workspace โŒ˜ + K, โŒ˜ + Down
Activate pane in direction left Workspace โŒ˜ + K, โŒ˜ + Left
Activate pane in direction right Workspace โŒ˜ + K, โŒ˜ + Right
Activate pane in direction up Workspace โŒ˜ + K, โŒ˜ + Up
Close all docks Workspace Alt + โŒ˜ + Y
New file Workspace โŒ˜ + N
New terminal Workspace Control + ~
New window Workspace โŒ˜ + Shift + N
Save Workspace โŒ˜ + S
Save all Workspace โŒ˜ + Alt + S
Save as Workspace โŒ˜ + Shift + S
Save without format Workspace โŒ˜ + K, S
Swap pane in direction Workspace โŒ˜ + K, Shift + Down
Swap pane in direction Workspace โŒ˜ + K, Shift + Left
Swap pane in direction Workspace โŒ˜ + K, Shift + Right
Swap pane in direction Workspace โŒ˜ + K, Shift + Up
Toggle bottom dock Workspace โŒ˜ + J
Toggle left dock Workspace โŒ˜ + B
Toggle right dock Workspace โŒ˜ + R
Unfollow Workspace Escape
Open keymap Zed โŒ˜ + K, โŒ˜ + S

Project Panel

Command Target Default Shortcut
Collapse selected entry Project Panel Left
Copy Project Panel โŒ˜ + C
Copy path Project Panel โŒ˜ + Alt + C
Copy relative path Project Panel Alt + โŒ˜ + Shift + C
Cut Project Panel โŒ˜ + X
Delete Project Panel Backspace
Delete Project Panel Delete
Delete Project Panel โŒ˜ + Backspace
Delete Project Panel โŒ˜ + Delete
Expand selected entry Project Panel Right
New directory Project Panel Alt + โŒ˜ + N
New file Project Panel โŒ˜ + N
New search in directory Project Panel Alt + Shift + F
Open Project Panel Space
Paste Project Panel โŒ˜ + V
Rename Project Panel Enter
Rename Project Panel F2
Reveal in File Manager Project Panel Alt + โŒ˜ + R
Command Target Default Shortcut
Search in new Project Search โŒ˜ + Enter
Toggle focus Project Search Escape
Activate regex mode Search Alt + โŒ˜ + G
Activate text mode Search Alt + โŒ˜ + X
Cycle mode Search Alt + Tab
Focus search Search โŒ˜ + Shift + F
Next history query Search Down
Previous history query Search Up
Replace all Search โŒ˜ + Enter
Replace next Search Enter
Toggle replace Search โŒ˜ + Shift + H

Terminal

Command Target Default Shortcut
Clear Terminal โŒ˜ + K
Copy Terminal โŒ˜ + C
Delete line Terminal โŒ˜ + Backspace
Move to beginning of line Terminal โŒ˜ + Left
Move to end of line Terminal โŒ˜ + Right
Move to next word end Terminal Alt + Right
Move to previous word start Terminal Alt + Left
Paste Terminal โŒ˜ + V
Show character palette Terminal Control + โŒ˜ + Space

Assistant Editor

Command Target Default Shortcut
Assist Assistant โŒ˜ + Enter
Cycle message role Assistant Control + R
Quote selection Assistant โŒ˜ + >
Split Assistant Shift + Enter
Save Workspace โŒ˜ + S