on master help sign in
doc: expand documentation on configuring minor modes

Fixes #3835, #4811

commit9530fab4b6f320d212f966e46a0353931a010471 authorClément Delafargue <clement@delafargue.name> dateTue 17 Jan 2023, 09:48 (4 years ago) parenta02dd17
2 files changed+28−2
book/src/keymap.md+3 book/src/remapping.md+25−2
book/src/keymap.md+3
@@ -166,6 +166,9 @@ These sub-modes are accessible from normal mode and typically switch back to nor
166166| `Ctrl-w` | Enter [window mode](#window-mode) | N/A |
167167| `Space` | Enter [space mode](#space-mode) | N/A |
168168
169+These modes (except command mode) can be configured by
170+[remapping keys](https://docs.helix-editor.com/remapping.html#minor-modes).
171+
169172#### View mode
170173
171174Accessed by typing `z` in [normal mode](#normal-mode).
book/src/remapping.md+25−2
@@ -25,8 +25,31 @@ j = { k = "normal_mode" } # Maps `jk` to exit insert mode
2525```
2626> NOTE: Typable commands can also be remapped, remember to keep the `:` prefix to indicate it's a typable command.
2727
28−> NOTE: Bindings can be nested, to create (or edit) minor modes: `g = { a = "code_action"}` adds a new entry to
29−> the `goto` mode.
28+## Minor modes
29+
30+Minor modes are accessed by pressing a key (usually from normal mode), giving access to dedicated bindings. Bindings
31+can be modified or added by nesting definitions.
32+
33+```toml
34+[keys.insert.j]
35+k = "normal_mode" # Maps `jk` to exit insert mode
36+
37+[keys.normal.g]
38+a = "code_action" # Maps `ga` to show possible code actions
39+
40+# invert `j` and `k` in view mode
41+[keys.normal.z]
42+j = "scroll_up"
43+k = "scroll_down"
44+
45+# create a new minor mode bound to `+`
46+[keys.normal."+"]
47+m = ":run-shell-command make"
48+c = ":run-shell-command cargo build"
49+t = ":run-shell-command cargo test"
50+```
51+
52+## Special keys and modifiers
3053
3154Ctrl, Shift and Alt modifiers are encoded respectively with the prefixes
3255`C-`, `S-` and `A-`. Special keys are encoded as follows: