Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom key macros #217

Merged
merged 1 commit into from
Mar 10, 2024
Merged

Add support for custom key macros #217

merged 1 commit into from
Mar 10, 2024

Conversation

ulyssa
Copy link
Owner

@ulyssa ulyssa commented Mar 10, 2024

This adds a "macros" field to config.json which allows specifying custom mappings from one set of keys to another. This allows writing something like the following to map jj to <Esc> in Insert mode:

{
    ...,
    "macros": {
        "i": { "jj": "<Esc>" }
    }
}

The following names can be used to refer to the different modes:

  • normal/n for Normal mode
  • insert/i for Insert mode
  • visual/v for Visual mode
  • command/c for Command mode
  • select for Select mode
  • operator-pending for Operator Pending mode

Multiple modes can be specified together using | to put a mapping in all of them. For example, "insert|command" or "i|c" could be used in the above example to map jj in both Insert and Command mode.

I've called this "macros" since they'll behave like macros: a {count} argument will repeat the mapping (<Esc> in the above example), and not provide an argument to it. I have plans for a separate way to specify keybindings in the future using expressions that generate an Action that should help anyone who needs to specify something that takes an optional count or register argument.

@ulyssa ulyssa enabled auto-merge (squash) March 10, 2024 06:35
@ulyssa ulyssa merged commit e7f158f into main Mar 10, 2024
4 checks passed
@ulyssa ulyssa deleted the custom-macro-bindings branch March 10, 2024 06:49
@ulyssa ulyssa added this to the v0.0.9 milestone Mar 29, 2024
@ulyssa ulyssa mentioned this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant