Skip to content

Revamp keybinding mechanism to support richer keybindings (e.g. ctrl-alt-shift-x )#5563

Merged
stefanhaller merged 10 commits into
masterfrom
keybinding-revamp
Apr 30, 2026
Merged

Revamp keybinding mechanism to support richer keybindings (e.g. ctrl-alt-shift-x )#5563
stefanhaller merged 10 commits into
masterfrom
keybinding-revamp

Conversation

@stefanhaller
Copy link
Copy Markdown
Collaborator

Revamp lazygit's keybinding mechanism to support richer keybindings for those terminals that support the newer keyboard protocols. This makes it possible to use keybindings such as ctrl-alt-shift-x.

Change the default keybindings for moving commits up and down from ctrl-k/ctrl-j to alt-up/alt-down; this is mostly for personal preference, I find them easier to remember, and they are nicely similar to moving a line of code up and down in many code editors. Also, change the default binding for submitting a commit from the commit description editor from alt-enter to command-enter on Mac, or ctrl-enter on Linux and Windows; these are the same bindings that are used in many multi-line edit field situations, e.g. in GitHub comments.

See docs/keybindings/Custom_Keybindings.md for caveats about terminal compatibility.

stefanhaller and others added 10 commits April 30, 2026 22:22
An uppercase letter is not valid with ctrl, and only works because we lowercase
the string before parsing it. This will change later in this branch when we
start supporting bindings like <c-s-r>.
So that it is next to KeyFromLabel.
Move keybindings.GetKey to config.GetValidatedKeyBindingKey
This changes not only how we store modifiers (inside of Key instead of passing
it separately), but also how we parse keybinding strings: it supports all
combinations of modifiers now (if the terminal supports it, that is).
The previous version only enumerated the supported (non-rune) bindings.
Replace it with a description of the syntax: how to spell single-rune
keys, special keys, and modified keys; how to combine modifiers; the
keyword forms for `<space>`, `<minus>`, `<plus>`; and which combinations
are rejected because terminals can't deliver them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
These are the same as many editors (e.g. VS Code) use for moving a line up/down,
so they are easy to remember.
@stefanhaller stefanhaller added the enhancement New feature or request label Apr 30, 2026
@stefanhaller stefanhaller enabled auto-merge April 30, 2026 20:28
@stefanhaller stefanhaller merged commit 396e1ae into master Apr 30, 2026
14 checks passed
@stefanhaller stefanhaller deleted the keybinding-revamp branch April 30, 2026 20:30
stefanhaller added a commit that referenced this pull request Apr 30, 2026
…5565)

In #5563 we started to support an alternative syntax for keybindings:
instead of `<c-a>` you could say `<ctrl+a>`, which is easier to read
especially when there are multiple modifiers (`<ctrl+shift+x>` instead
of `<c-s-x>`). In this PR we make this new syntax the default.
stefanhaller added a commit that referenced this pull request May 6, 2026
Followup to #5563; I forgot to do this there.
@stefanhaller stefanhaller changed the title Keybinding revamp Revamp keybinding mechanism to support richer keybindings (e.g. ctrl-alt-shift-x ) May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant