Skip to content

Commit

Permalink
doc: expand documentation on configuring minor modes
Browse files Browse the repository at this point in the history
Fixes #3835, #4811
  • Loading branch information
divarvel authored and the-mikedavis committed Jan 17, 2023
1 parent a02dd17 commit 9530fab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ These sub-modes are accessible from normal mode and typically switch back to nor
| `Ctrl-w` | Enter [window mode](#window-mode) | N/A |
| `Space` | Enter [space mode](#space-mode) | N/A |

These modes (except command mode) can be configured by
[remapping keys](https://docs.helix-editor.com/remapping.html#minor-modes).

#### View mode

Accessed by typing `z` in [normal mode](#normal-mode).
Expand Down
27 changes: 25 additions & 2 deletions book/src/remapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,31 @@ j = { k = "normal_mode" } # Maps `jk` to exit insert mode
```
> NOTE: Typable commands can also be remapped, remember to keep the `:` prefix to indicate it's a typable command.
> NOTE: Bindings can be nested, to create (or edit) minor modes: `g = { a = "code_action"}` adds a new entry to
> the `goto` 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.

```toml
[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"
```

## 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:
Expand Down

0 comments on commit 9530fab

Please sign in to comment.