reddit / emacs
Text navigation gripe: backward-char (C-b) and backward-word (M-b)
republic_of_mao · 2022-11-16 04:13
I'm not going to switch over to vi bindings, but in exploring how the other 2/3 lives, I've grown disenchanted with Emacs's keybindings for `(backward-char)` and `(backward-word)`. For decades, I've used `<left>` and `M-<left>` for those navigation commands, but as I've moved away from the arrow keys in favor of `C|M-`{`f`, `n`, `p`} , I've found the `b` variant more and more irritating. For me, `C-` is caps-lock and `M-` sits just below `x`. In both cases, combining them with `b` makes for a very weird hand shape.
vi's `h,j,k,l` navigation is interesting, but `n,p` make more sense to me than `j,k` and I use `C-h`, `C-l` and `M-l` enough to not want to remap them.
I'm interested to hear about solutions to this thorn from people who don't use vi bindings.
Illiamen · 2022-11-16 04:32
> For me, `C-` is caps-lock and `M-` sits just below `x`. In both cases, combining them with `b` makes for a very weird hand shape.
Use both hands. It's much more comfortable.
phalp · 2022-11-16 05:17
Ah, control on the caps lock key. Classic mistake.
thetemp_ · 2022-11-16 05:52
> In both cases, combining them with b makes for a very weird hand shape.
Are you trying to press the modifier and "b" with the same hand? That's probably a bad practice, as it requires your hand to contort itself repetitively. Better to touch-type and use both hands when pressing letter keys and modifiers at the same time.
Some people love the Caps-Lock as Ctrl, but then other people claim that it too gave them Emacs-pinky.
I've tried different approaches using [Kmonad](https://github.com/kmonad/kmonad). You can do home-row modifiers, number-row modifiers, and whatever other combinations you can think of. Right now, I have space-bar doubling as my Ctrl key. It works pretty well, since my thumbs are already over it almost all the time that I'm typing.
arthurno1 · 2022-11-16 08:36
> Use both hands. It's much more comfortable.
Unfortunately, not everyone can use both hands, and I am not talking about rare cases of disabled people without one hand.
Some keyboards use right-alt, as "graphic alt", at least many European keyboards use it to enter special symbols like @$€[], etc. For programming, not so surprisingly either, the US layout is the best. For a while I used a US keyboard and mapped Swedish letters to others, but then using another keyboard than my own was a pain, so I gave up on that one.
I totally understand Op here, I also found using, M-x difficult, since I have to fold my thumb quite a bit under the palm which is uncomfortable. For that reason, I have since a few years back remapped M-x to C-z, so now I can use both hands again :). I have also remapped C-v to act as a prefix, so I have a row of modifiers to use with Ctrl; z, x, c, and v, all sitting next to each other, which is sort of easy to remember (for me at least). Unfortunately, since I use C-z as a prefix, I can't use it for simple shortcuts like M-b; but I can live without.
arthurno1 · 2022-11-16 08:45
> Are you trying to press the modifier and "b" with the same hand? That's probably a bad practice, as it requires your hand to contort itself repetitively.
Some keyboards don't have two alt keys, instead they have Alt and Alt-graphic (european keyboards) which enters graphic symbols like @£$€{[]}\± (on my keyboard), so you can't use them interchangeably like Alt on a US keyboard.
> I have space-bar doubling as my Ctrl key.
How do you enter space?
thetemp_ · 2022-11-16 13:51
> How do you enter space?
With the space bar. :-D
If I tap it, it emits a space. If I hold it down, it works as a Ctrl modifier.
It's actually a bit more complex than that. There's a timeout mechanism to avoid accidental commands from typing quickly. That used to happen occasionally before I figured out the right setting.
There is more detail about how it works in the [Multi-use buttons section](https://github.com/kmonad/kmonad/blob/820af08d1ef1bff417829415d5f673041b67ef4d/keymap/tutorial.kbd#L674) of the Kmonad tutorial.
weelyat · 2022-11-16 14:40
I hit b with my right index finger and I too have remapped CapsLock and Ctrl. (Without that Ctrl-t is nearly impossible)
jaredj · 2022-11-16 16:22
Ergoemacs, boon, and xah-fly-keys all deal with this, in ways different from both the default Emacs keybindings and from vi keybindings.
Xah Lee convinced me that I don't owe anything to historical keybindings when my keyboard is a different shape from the ones where the bindings were invented. See http://xahlee.info/kbd/keyboard_hardware_and_key_choices.html.
jackcviers · 2022-11-16 18:37
The solution there is to remap your keyboard layout such that Right-M is on a different key -- Higher FN keys, PageDown, PageUp, Windows Menu Key, etc. I use a bunch of different keyboards, and when the keyboard has onboard key remapping I use that to define the key to be wherever is most convenient.
On the other keyboards, there are good keyboard gui software utilities available:
Linux: The [Gnome Tweak Tool](https://youtu.be/_KgeyOMXLUU) on gnome-based desktops for linux has a couple dozen options that don't involve direct xmodmap usage. There are similar tools on other distributions.
Mac: has several options under modifier keys in the keyboard settings.
Windows: [PowerToys](https://community.chocolatey.org/packages/powertoys) has similar keyboard remapping utilities.
There's also a guide on [EmacsWiki](https://www.emacswiki.org/emacs/MetaKeyProblems#h5o-9) for if any of the above options don't work for you.
You can also use Sticky Keys on [Mac](https://www.disability.illinois.edu/academic-support/assistive-technology/mac-os-x-sticky-keys)/[Windows](https://geekflare.com/using-sticky-keys-in-windows/).
You can ditch the `C-` `M-` key usage almost entirely with [god-mode](https://github.com/emacsorphanage/god-mode), and have full control over entering `god-mode-all` with a custom keybinding that you have control over, and control the keybindings when in `god-mode` that will trigger the `M-` when in `god-mode`.
Or just rebind the command to a keyboard shortcut you feel more comfortable with `global-set-key`
arthurno1 · 2022-11-16 18:58
> The solution there is to remap your keyboard layout
As I wrote, for me, layout remapping wasn't a good option:
> For a while I used a US keyboard and mapped Swedish letters to others, but then **using another keyboard than my own was a pain**, so I gave up on that one.
It is much easier to use another prefix for M-x in Emacs, than to remap the entire keyboard layout. Generally, I am OK with Ctrl. As a guitar and piano player, and 20+ years of Emacs user, I am not a believer of "emacs pinky", so I am OK to have left and right ctrl; only problem was M-x since I am using a Swedish keyboard, as explained in the above comment.
> Or just rebind the command to a keyboard shortcut you feel more comfortable
Which is exactly what I did and told about in the comment you answered to.
Yes, it is possible to minimize on the usage of modifiers, or to remap them, you have forgotten to mention evil/viper modes, which is another option. As someone said in this forum once, keyboard bindings are like underwear, everyone has their own.
Anyway, thank you for your advice, maybe someone else will find it useful, it is probably good to have it all in one place.
republic_of_mao · 2022-11-17 02:12
I don't have any issue with \`M-x\` (thumb+middle). It's \`M-b\` (thumb+L-index or thumb+R-index).
I may try god-mode at some point, but I was hoping for some other ideas.
republic_of_mao · 2022-11-17 02:18
haha -- I had the same question when I saw your post. maybe I'll try this -- it's promising that works under both GNU/Linux & OSX.
republic_of_mao · 2022-11-17 02:19
True, I don't owe anything to historical keybindings, but I do owe something to decades of muscle memory!
republic_of_mao · 2022-11-18 20:33
Kmonad looks interesting, but under OSX, it's only supported to the one before Monterrey (I can't recall the version #s). As I've learned with Apple, if they can pull the rug out from under you, they will. It's just a matter of time.
I think that puts god-mode ahead of Kmonad for me. Or for me to learn to use R-alt (right of space).
tdavey · 2022-11-20 20:21
You said the most important words: "muscle memory." You should rebind keys to accord with your ingrained muscle memory. For example, to cite the two movements you cite, I have bound:
1. backward character = C-s
2. backward word = C-a
Why these choices? Because they were native to Wordstar, the editor with which I first learned to type on a computer keyboard. These bindings have stuck with me for four decades.
Hence Emacs. Emacs is expressly designed to make easy for me to use MY preferred bindings. Emacs doesn't force me to use its bindings.
This is, of course, what Evil does too. It turned Emacs into Vim. I've turned it into Wordstar. My friend, turn Emacs into whatever YOUR fingers instinctively want it to be.
republic_of_mao · 2022-11-24 05:35
Wordstar! I remember using that in the mid 80's. Kudos to you for keeping the keybindings! Your C-s and C-a are interesting, but for me that's long been hard-wired to search and beginning-of-line.
The trouble is finding something that doesn't push on something else that I already use. Nonetheless, its good to find out what others are doing.
I've started poking the "b" with my right index finger more often, but I don't know how long I'll keep that.