Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Key remapping

Keybindings can run:

  • Static commands, such as move_char_right, for movement and editing.
  • Typable commands, such as :write, which also work from command mode.
  • Macros, such as @miw, which replay key sequences.

See Commands for the command lists. In macros, wrap modified and special keys in angle brackets, such as @miw<A-o>. A macro must be the only item in a binding; it cannot be combined with other commands in a list.

Open config.toml with :config-open and add your bindings. Modifier prefixes use C- for Ctrl, A- for Alt, and S- for Shift. For example:

[keys.normal]
C-s = ":write"
ret = ["open_below", "normal_mode"]
A-x = "@x<A-d>" # Select a line and delete it without yanking.

# Replace Space f with a labeled menu.
[keys.normal.space.f]
label = "File"
f = "file_picker"
s = { label = "Save", command = ":write" }
c = { label = "Edit config", command = ":config-open" }

[keys.insert]
j = { k = "normal_mode" } # Press j, then k, to leave insert mode.

label sets the menu title or the description shown for a command binding. Menus can be nested and labeled at any depth. Labels also override the names of built-in menus while keeping their other bindings. Trusted workspace labels override global labels; omitting a label or setting it to an empty string keeps the existing menu title or command description.

The command field accepts a command string or an array of commands. A binding cannot contain both command and nested keybindings. Individual static commands keep their built-in descriptions; sequences may contain static and typable commands and have their own label. Macros cannot be used in command sequences. These labels apply to editor mode maps (normal, insert, and select).

Minor modes

Minor modes are accessed by pressing a key (usually from normal mode), giving access to dedicated bindings. Bindings can be modified or added by nesting definitions.

[keys.insert.j]
k = "normal_mode" # Maps `jk` to exit insert mode

[keys.normal.g]
a = "code_action" # Maps `ga` to show possible code actions

# invert `j` and `k` in view mode
[keys.normal.z]
j = "scroll_up"
k = "scroll_down"

# create a new minor mode bound to `+`
[keys.normal."+"]
m = ":run-shell-command make"
c = ":run-shell-command cargo build"
t = ":run-shell-command cargo test"

Component keys

Prompts, pickers, menus, and popups have their own action maps. Hover pages and signature overloads can also be remapped. Each table accepts the actions listed below; action names are local to that component.

[keys.picker]
C-j = "move_down"
C-k = "move_up"
C-space = "accept"
C-n = "unbound" # Release this key to the picker's prompt.

[keys.buffer-picker]
C-x = "close_buffer" # Close the selected buffer and keep the picker open.

[keys.git-picker]
C-x = "actions"

[keys.stash-picker]
C-x = "apply_stash"

[keys.file-explorer]
F2 = "move_path"

[keys.prompt]
C-j = "accept"
C-x = { h = "move_start", l = "move_end" }
A-backspace = ["delete_word_backward", "delete_word_backward"]

[keys.menu]
C-j = "move_down"
C-k = "move_up"

[keys.popup]
C-j = "scroll_down"
C-k = "scroll_up"

[keys.signature-help]
A-j = "next"
A-k = "previous"

[keys.hover]
A-j = "next"
A-k = "previous"

Bindings merge with the defaults. Trusted project settings override your user settings. :config-reload also updates components that are already open.

Use no_op to consume a key without doing anything. Use unbound to remove its action and let the usual fallback handle it. For example, a key unbound in keys.picker can edit the picker’s query through keys.prompt.

Nested maps wait for another key. Esc or an invalid continuation cancels the sequence and consumes that key. Pasting into a prompt cancels a pending sequence and inserts the pasted text. Action lists run in order and stop when an action closes the component or starts another interaction.

Picker actions take priority over prompt actions. Menu actions take priority over popup actions. To pass Ctrl-d through a completion menu and its popup to an editor binding, set C-d = "unbound" in both keys.menu and keys.popup. To remap Esc inside an insert-mode menu, also set esc = "unbound" in keys.popup so the popup passes it to the menu.

Component bindings accept only the actions below. Editor commands and macros belong in keys.normal, keys.insert, and keys.select.

TableActions
keys.promptaccept, cancel, move_left, move_right, move_word_left, move_word_right, move_word_end, move_start, move_end, delete_backward, delete_forward, delete_word_backward, delete_word_forward, delete_to_start, delete_to_end, insert_word, insert_register, history_previous, history_next, complete_previous, complete_next, exit_selection, toggle_search_syntax
keys.pickeraccept, accept_keep_open, accept_horizontal_split, accept_vertical_split, open_all, cancel, move_up, move_down, move_start, move_end, page_up, page_down, toggle_preview, toggle_loading, populate_quicklist, toggle_replacement, toggle_case_sensitive, replace_all, preview_scroll_up, preview_scroll_down, preview_previous, preview_next, open_preview
keys.buffer-pickerAll keys.picker actions, plus close_buffer
keys.quicklist-pickerAll keys.picker actions, plus remove_entry
keys.git-pickerAll keys.picker actions, plus stage, unstage, stash, actions, stashes
keys.branch-pickerAll keys.picker actions, plus create_branch, delete_branch
keys.worktree-pickerAll keys.picker actions, plus create_worktree, remove_worktree, lock_worktree, unlock_worktree
keys.stash-pickerAll keys.picker actions, plus apply_stash, apply_stash_with_index, actions
keys.history-pickerAll keys.picker actions, plus actions, back
keys.file-explorerAll keys.picker actions, plus create_path, move_path, copy_path, delete_path, yank_path
keys.sidebar, keys.sidebar-filterAll keys.file-explorer actions, plus filter, focus_editor, hide, next_view, previous_view, resize, fold_open, fold_close, fold_toggle, fold_all
keys.menuaccept, cancel, move_up, move_down, page_up, page_down
keys.popupcancel, scroll_up, scroll_down
keys.hover, keys.signature-helpprevious, next
keys.blamecopy_commit_id, copy_message
keys.diffscroll_left, scroll_right, restore (current-change popup only)

All component tables also accept no_op and unbound. Popup scrolling and menu paging move by half a page. Picker paging moves by a full page.

keys.buffer-picker, keys.quicklist-picker, keys.git-picker, keys.branch-picker, keys.worktree-picker, keys.stash-picker, keys.history-picker, and keys.file-explorer inherit keys.picker. Picker-specific bindings take priority over shared picker bindings, including ones from project configuration. The quicklist picker also binds Ctrl-x to remove_entry by default.

open_all opens each distinct file or buffer referenced by the current matches. It skips directories and asks for confirmation above 50 targets. The default key is Alt-a, or Alt-Shift-a in the Git changed-files picker.

close_buffer closes the selected buffer while keeping the picker open. It waits for pending saves and refuses to discard unsaved changes. After closing, the query is kept and a nearby row becomes selected. The action stops the current action list. It has no default binding.

remove_entry removes the highlighted quicklist entry while keeping the picker open, preserving the filter and selecting a nearby row. It stops the current action list. See Quicklist for adding and removing locations.

The sidebar inherits keys.file-explorer bindings. Use keys.sidebar to override navigation bindings and keys.sidebar-filter to override bindings while editing its filter. The editor shortcut is switch_sidebar_focus under keys.normal and keys.select.

Special keys and modifiers

Ctrl, Shift and Alt modifiers are encoded respectively with the prefixes C-, S- and A-.

The Super key - the Windows/Linux key or the Command key on Mac keyboards - is also supported when using a terminal emulator that supports the enhanced keyboard protocol. The super key is encoded with prefixes Meta-, Cmd- or Win-. These are all synonyms for the super modifier - binding a key with a Win- modifier will mean it can be used with the Windows/Linux key or the Command key.

[keys.normal]
C-s = ":write" # Ctrl and 's' to write
Cmd-s = ":write" # Cmd or Win or Meta and 's' to write

Special keys are encoded as follows:

Key nameRepresentation
Backspace"backspace"
Space"space"
Return/Enter"ret"
Left"left"
Right"right"
Up"up"
Down"down"
Home"home"
End"end"
Page Up"pageup"
Page Down"pagedown"
Tab"tab"
Delete"del"
Insert"ins"
Null"null"
Escape"esc"
Less Than (<)"lt"
Greater Than (>)"gt"

Keys can be disabled by binding them to the no_op command.

All other keys such as ?, !, - etc. can be used literally:

[keys.normal]
"?" = ":write"
"!" = ":write"
"-" = ":write"

Note: - can’t be used when combined with a modifier, for example Alt + - should be written as A-minus. A-- is not accepted.