Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Assign all keymap action into commands (ability to remap action utilize assigned number and register) #1200

Closed
NNBnh opened this issue Nov 30, 2021 · 1 comment
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@NNBnh
Copy link
Contributor

NNBnh commented Nov 30, 2021

From the look of the current key remapping docs, there is currently no way remap action utilize assigned number/count or register.

There is 2 solution that i could thinks of:

1. Quick approach

"L" = [5, "move_next_word_end"] # move 5 word_end right
"A-l" = ["move_line_up", "number", "move_char_right"] # move up then move N char right
# N == assigned number before the key is pressed.

"Y" = ["a", "yank"] # yank to "a" slot
"A-y" = ["clipboard", "yank"] # yank to clipboard
"D" = ["nul", "delete_selection"] # delete selection without yank
"A-Y" = ["switch_to_uppercase", "register", "yank"] # upper case selected text then yank to R slot
# R == assigned register before the key is pressed.

This method feel kind of janky and i much prefer the 2nd approach:

2. Consistent approach (Emacs approach)

Emacs full name is "Editor MACroS" and as the name suggest, all action in Emacs is a macro/command. So remapping key is simply assign a command to a button:

(global-set-key (kbd "M-l") 'forward-char)

I found this approach make the editor very consistent:

  • The good news is there is already an PR feat: Make it possible to keybind TypableCommands #1169 that could make this be possible.
  • The bad new is we need to turn all keymaps action in to commands (a mountain of work), then somehow hide them from the command mode so the command mode don't get polluted
"L" = ["goto word_end right 5"] # move 5 word_end right
"A-l" = ["goto char up", "goto right number"] # move up then move N char right
# N == assigned number before the key is pressed.

"Y" = ["yank a"] # yank to "a" slot
"A-y" = ["yank clipboard"] # yank to clipboard
"D" = ["delete nul"] # delete selection without yank
"A-Y" = ["case up", "yank register"] # upper case selected text then yank to R slot
# R == assigned register before the key is pressed.

Please consider implement this approach because this will improve the keybind and upgradability in the long run

@NNBnh NNBnh added the C-enhancement Category: Improvements label Nov 30, 2021
@kirawi kirawi added the A-keymap Area: Keymap and keybindings label Nov 30, 2021
@NNBnh NNBnh mentioned this issue Dec 9, 2021
@NNBnh NNBnh changed the title Ability to remap action utilize assigned number and register Assign all keymap action into commands (ability to remap action utilize assigned number and register) Dec 27, 2021
@eugenesvk
Copy link

eugenesvk commented Jan 10, 2022

If I remap 09 numbers to commands (which I'd very much like to do as I think they'd be much more useful that way), how would I enter N in this example?

"A-l" = ["goto char up", "goto right number"] # move up then move N char right
# N == assigned number before the key is pressed.

I thought we could have a "number prefix" (for example, 0), which would treat all subsequent numbers as the number argument rather than whatever the command is assigned to a given number key (like the Emacs' "universal argument" command). So I'd just have to press an extra 0 before each number argument to retain the previous behavior — and be able to use numbers without any modifiers to execute commands! Win-win :)!

@helix-editor helix-editor locked and limited conversation to collaborators Apr 7, 2024
@pascalkuthe pascalkuthe converted this issue into discussion #10230 Apr 7, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants