reddit / emacs
Customizing Emacs bindings for custom keyboard layouts
dobeye · 2022-07-29 10:57
Hey all! I'm currently using vim, but I was having some serious issues and wanted to know if Emacs could save the day. I use a non QWERTY keyboard layout (rsthd), and that makes using vim TERRIBLE, so like any normal person I changed my vim bindings to my layout. This caused a lot of issues regarding combos, and when I asked the vim community they said changing the default keymappings is a bad idea and I should just learn the default ones on my layout. I wanted to know how hard configuring Emacs is with a custom layout, maybe I should just switch sides.
Tl;dr how does Emacs handle changing default keybindngs compared to vim?
publicvoit · 2022-07-29 11:33
Just to give you food for thought: you also can modify your keyboard interface and not the bindings, e.g., like I did with my ergonomic Kinesis Advantage2 and its QMK-adaptation: https://karl-voit.at/2021/03/21/advantage2-plans/ and https://karl-voit.at/2021/05/23/advantage2-modifications/
L-Szos · 2022-07-29 12:00
Emacs keybindings are deeply malleable. You can remap pretty much everything, though it may lead to a large number of binding expressions in your init file. You can use `keyboard-translate` to "swap" keys, which in conjunction with plain old key binding should be enough to do what youd like.
dobeye · 2022-07-29 12:08
And are they consistent? If I change i to j (random change for the sake of example) do all commands that include i change accordingly?
L-Szos · 2022-07-29 12:10
If you use `keyboard-translate` emacs wont see the original key, only the translated key. So if you translate i to j then emacs will see a j key press whenever you press i. To my knowledge this change effects everything as it happens before key binding lookups.
dobeye · 2022-07-29 12:37
Unless I'm inserting text, right?
[deleted] · 2022-07-29 12:52
[deleted]
cazzipropri · 2022-07-29 13:48
In emacs you can do everything you want.
I use a vintage 122-key keyboard with 32 function keys and a USB converter that allows you to reprogram any key. I remapped emacs' bindings radically to map all the functions I use the most to one keystroke.
Just for inspiration, take a look at [https://github.com/scarpazza/battlecruiser](https://github.com/scarpazza/battlecruiser) and [https://github.com/scarpazza/dot-emacs](https://github.com/scarpazza/dot-emacs)
It's not going to be what you want, because we are all very particular with key bindings, but it might give you ideas.
thetemp_ · 2022-07-29 19:38
Even when you're inserting text. But Emacs commands are chorded. So if you are translating C-y to C-n, that doesn't change the effect of pressing y by itself.
If you plan to use evil-mode (Vim bindings in Emacs), it would be more complicated.
xtifr · 2022-07-29 21:28
Emacs keybindings are *so* malleable that it includes modes which emulate two other editors (vi and edt) out of the box, and an enhanced version of the vi emulation which provides proper vim emulation (not just vi) is one of the more popular add-on packages.
11fdriver · 2022-07-30 00:34
Hey! I'm also non-QWERTY (Dvorak/Halmak)
While sometimes a hassle, I'd strongly encourage anyone to modify their keybindings, just for the understanding it will give you of your own editing flow.
So go for it; your editor should change to fit you, not vice versa, and Emacs makes that pretty simple.
You could also take a look at non-mnemonic keybinding packages like `xah-fly-keys`, which has (if I recall correctly) a way of adding new layouts quite painlessly.
I'd personally recommend trying out `modalka` or `ryo-modal`. They're very light packages that let you create your own keybinding layer to switch to.
Also, install `which-key`!