Remapping
Helix currently supports one-way key remapping through a simple TOML configuration file. (More powerful solutions such as rebinding via commands will be available in the future).
There are three kinds of commands that can be used in keymaps:
Types of Commands
Static Commands
Commands like move_char_right which are usually bound to keys and used for movement and editing.
A list of static commands is available in the Keymap documentation and in the source code in helix-term/src/commands.rs ↗
Typable Commands
Commands that can be executed from command mode (:), for example :write!.
See the Typed Commands documentation for a list of available typeable commands.
Also available at TypableCommandList declaration in the source code at helix-term/src/commands/typed.rs ↗.
Remapping
To remap keys, create a config.toml file in your helix configuration
directory (default ~/.config/helix on Linux systems) with a structure like
this:
To set a modifier + key as a keymap, type A-X = ... or C-X = ... for Alt + X or Ctrl + X. Combine with Shift using a dash, e.g. C-S-esc.
Within macros, wrap them in <>, e.g. <A-X> and <C-X> to distinguish from the A or C keys.
Example
# At most one section each of 'keys.normal', 'keys.insert' and 'keys.select'[keys.normal]# Maps Ctrl-s to the typable command :w which is an alias for :write (save file)C-s = ":w"
# Maps Ctrl-o to opening of the helix config fileC-o = ":config-open"
# Maps the 'a' key to the move_char_left commanda = "move_char_left"
# Maps the 'w' key move_line_upw = "move_line_up"
# Maps Ctrl-Shift-Escape to extend_line"C-S-esc" = "extend_line"
# Maps `ga` to show possible code actionsg = { a = "code_action" }
# Maps the enter key to open_below then re-enter normal mode"ret" = ["open_below", "normal_mode"]
# Maps Alt-x to a macro selecting the whole line and deleting it without yanking it"A-x" = "@x<A-d>"
[keys.insert]# Maps Alt-X to enter normal mode"A-x" = "normal_mode"
# Maps `jk` to exit insert modej = { k = "normal_mode" }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]# Maps `jk` to exit insert modek = "normal_mode"
[keys.normal.g]# Maps `ga` to show possible code actionsa = "code_action"
# 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"Special keys and modifiers
Ctrl, Shift and Alt modifiers are encoded respectively with the prefixes
C-, S- and A-. Special keys are encoded as follows:
| Key name | Representation |
|---|---|
| Backspace | "backspace" |
| Space | "space" |
| Return or Enter | "ret" |
| - | "minus" |
| 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" |
Other keys such as /, + and ? can be referenced literally.
Keys can be disabled by binding them to the no_op command.