Hacker News new | ask | show | jobs
by JoshMcguigan 2129 days ago
When I was first learning Vim I remapped caps lock to escape, and it was a huge improvement. But as I became more comfortable in Vim I realized I was using the control key a lot.

I've since remapped caps lock to control, and use ctrl-[ as escape (this is default behavior). I find having an easily accesible control key is very useful, even outside Vim. You can see in your link that it is actually the control key that used to be in the position we now put the caps lock key.

It does seem like remapping caps lock to escape when pressed alone and control when pressed with another key would be nice, but that wasn't an option for me (on wayland) as far as I know.

I bring this up only because there was a week or two transition period when I made this change, and I probably would have been better off if I had mapped caps lock to control from the start.

4 comments

On Linux and Mac it’s possible to have caps be escape when pressed alone or control when pressed with another key. On Linux the software is called xcape. :)
There's also caps2esc, which works even on the tty. https://gitlab.com/interception/linux/plugins/caps2esc
On Mac, there is Karabiner-Elements.

https://karabiner-elements.pqrs.org/

Here's a Karabiner tutorial that worked for me: https://medium.com/@pechyonkin/how-to-map-capslock-to-contro...
I recently learned this trick since getting a new MacBook pro with the touch bar esc key. I couldn't stand the lack of travel and didn't want to remap keys, now I use the ctrl-[ combo on all keyboards out of habit
Relevant to the other conversations going on in this thread, how simple is it to re-map that ctrl-[ to work globally? I'm assuming I'd have to install something for this. I am also using a Mac and use the caps-lock-as-escape to, say, close my spotlight search bar after activating it using the command+space shortcut.
In theory at least Ctrl-[ "is" Escape and is already universal. Reason: simultaneously pressing Ctrl is the ASCII -> ASCII mathematical transformation "subtract 0x40" for keys that represent a single ASCII character. So for example Ctrl-M is 0x4d - 0x40 = 0x0a. M is 0x4d ASCII and carriage return (aka '\r', aka Enter) is 0x0d ASCII. Ctrl-M is, or at least should be, universally the same as Enter. Similarly '[' is 0x5b in ASCII, so Ctrl-'[' is 0x1b in ASCII which is the ASCII code for, you guessed it I hope, Escape. Phew that was tough on a phone.
that's funny - I'm currently trying the jj remap, but I keep going for esc out of habit
This is what I do on both Linux and macOS. I like remapping Caps Lock to Ctrl/Command because it's the UNIX-style key layout I'm used to on the old IBM Model M keyboards, and my left and right pinky fingers are used to the Ctrl-[ combination, it's burned into muscle memory.
I remap my right Alt to Ctrl. The best thing I have ever done with regards to ergonomics. It works wonders in all softwares, not only vim. It's much more convenient to press with the thumb than CapsLock is with the pinkie.