Skip to content

Commit

Permalink
docs: describe another way to customize keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 30, 2024
1 parent cb7a33a commit 5497c11
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
36 changes: 32 additions & 4 deletions docs/configuration/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: Learn how to configure keyboard shortcuts with Yazi.
If you haven't created and used your own configuration file yet, please see [Configuration](./overview.md).
:::

You can change Yazi's key bindings in your `keymap.toml` file, which consists of the following 6 sections:
You can change Yazi's keybindings in your `keymap.toml` file, which consists of the following 6 sections:

- [\[manager\]](#manager) - File list.
- [\[tasks\]](#tasks) - Task manager.
Expand All @@ -18,7 +18,7 @@ You can change Yazi's key bindings in your `keymap.toml` file, which consists of
- [\[completion\]](#completion) - Completion component. e.g. "cd" path completion.
- [\[help\]](#help) - Help menu.

In each section, there are two attributes: `prepend_keymap` and `append_keymap`. You can use them to prepend or append to [the default key bindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml), for example:
In each section, there are two attributes: `prepend_keymap` and `append_keymap`. You can use them to prepend or append to [the default keybindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml), for example:

```toml
[manager]
Expand All @@ -30,12 +30,40 @@ append_keymap = [
]
```

When you don't need any default and want to fully customize your key bindings, use `keymap`, for example:
Or in another different style:

```toml
[[manager.prepend_keymap]]
on = [ "<C-a>" ]
exec = 'my-fev-command1'
desc = "Just for test!"

[[manager.append_keymap]]
on = [ "<C-b>" ]
exec = 'my-fev-command2'
desc = "Just for test!"
```

But keep in mind that you can only choose one of them, and it cannot be a combination of the two, as TOML language does NOT allow this:

```toml
[manager]
prepend_keymap = [
{ on = [ "<C-a>" ], exec = 'my-fev-command1', desc = "Just for test!" },
]

[[manager.prepend_keymap]]
on = [ "<C-b>" ]
exec = 'my-fev-command2'
desc = "Just for test!"
```

When you don't need any default and want to fully customize your keybindings, use `keymap`, for example:

```toml
[manager]
keymap = [
# This will override all default key bindings, and just keep the two below.
# This will override all default keybindings, and just keep the two below.
{ on = [ "<C-a>" ], exec = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "<C-b>" ], exec = 'my-fev-command2', desc = "Just for test!" },
]
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Learn how to configure Yazi.
There are three configuration files for Yazi:

- [`yazi.toml`](./yazi.md) - General configuration.
- [`keymap.toml`](./keymap.md) - Keybinds configuration.
- [`keymap.toml`](./keymap.md) - Keybindings configuration.
- [`theme.toml`](./theme.md) - Color scheme configuration.

You can find the default configuration files at https://github.com/sxyazi/yazi/tree/main/yazi-config/preset.
Expand Down
2 changes: 1 addition & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ To use it, copy the function into the configuration file of your respective shel
## Keybindings
:::tip
For all key bindings, see the [default `keymap.toml` file](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml).
For all keybindings, see the [default `keymap.toml` file](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml).
:::
### Navigation
Expand Down

0 comments on commit 5497c11

Please sign in to comment.