on 6c11708 help sign in
helix/book/src/remapping.md
59 lines 2.6 kB history raw
1# Key Remapping
3One-way key remapping is temporarily supported via a simple TOML configuration
4file. (More powerful solutions such as rebinding via commands will be
5available in the future).
7To remap keys, write a `config.toml` file in your `helix` configuration
8directory (default `~/.config/helix` in Linux systems) with a structure like
9this:
11```toml
12# At most one section each of 'keys.normal', 'keys.insert' and 'keys.select'
13[keys.normal]
14C-s = ":w" # Maps the Control-s to the typable command :w which is an alias for :write (save file)
15C-o = ":open ~/.config/helix/config.toml" # Maps the Control-o to opening of the helix config file
16a = "move_char_left" # Maps the 'a' key to the move_char_left command
17w = "move_line_up" # Maps the 'w' key move_line_up
18"C-S-esc" = "extend_line" # Maps Control-Shift-Escape to extend_line
19g = { a = "code_action" } # Maps `ga` to show possible code actions
20"ret" = ["open_below", "normal_mode"] # Maps the enter key to open_below then re-enter normal mode
22[keys.insert]
23"A-x" = "normal_mode" # Maps Alt-X to enter normal mode
24j = { k = "normal_mode" } # Maps `jk` to exit insert mode
25```
26> NOTE: Typable commands can also be remapped, remember to keep the `:` prefix to indicate it's a typable command.
28Control, Shift and Alt modifiers are encoded respectively with the prefixes
29`C-`, `S-` and `A-`. Special keys are encoded as follows:
31| Key name | Representation |
32| --- | --- |
33| Backspace | `"backspace"` |
34| Space | `"space"` |
35| Return/Enter | `"ret"` |
36| < | `"lt"` |
37| \> | `"gt"` |
38| \+ | `"plus"` |
39| \- | `"minus"` |
40| ; | `"semicolon"` |
41| % | `"percent"` |
42| Left | `"left"` |
43| Right | `"right"` |
44| Up | `"up"` |
45| Down | `"down"` |
46| Home | `"home"` |
47| End | `"end"` |
48| Page Up | `"pageup"` |
49| Page Down | `"pagedown"` |
50| Tab | `"tab"` |
51| Delete | `"del"` |
52| Insert | `"ins"` |
53| Null | `"null"` |
54| Escape | `"esc"` |
56Keys can be disabled by binding them to the `no_op` command.
58Commands can be found at [Keymap](https://docs.helix-editor.com/keymap.html) Commands.
59> Commands can also be found in the source code at [`helix-term/src/commands.rs`](https://github.com/helix-editor/helix/blob/master/helix-term/src/commands.rs) at the invocation of `static_commands!` macro and the `TypableCommandList`.