Hacker News new | ask | show | jobs
by nsomaru 3186 days ago
Remap single tap CAPS to ESC and when used in combination with another key or long-pressed - CTRL. This has changed the way I use my keyboard in vim and tmux.

I'm doing this on Ubuntu, but there are ways to get it done on OSX too.

4 comments

I have `jk` mapped to ESC in spacemacs, zsh and anything else I can set up to use vi keybindings. `jk` is essentially a no-op in vi, so rebinding it doesn't cause any issues while carrying the advantage that my fingers never have to leave the home row.
Out of curiosity, how do you type "Dijkstra" in that case?
I've never typed Dijkstra in Vim, but if I had to, there are two reasonable options:

1. Wait a half-second after typing the "j". That causes the mapping to time out and you can type the "k" without a problem.

2. Type something like Dijj<del>kstra.

Copy and paste from another window? If your use of the word "Dijkstra" is frequent enough for this method to bother you, there must be other mappings that would work.
I have a similar key binding set up. One option is to press a key that doesn't do anything in between.
I loved his solution until this. This is a deal breaker. Time to go back to the abbacus. ;)
It’s even easier now; the keyboard prefs in settings allows caps to esc reassignment through the UI.
Do you have any hints on how one might implement this on mac OS? I'd love to have my keyboard configured like this...
you can do it with the app karabiner elements.

once installed, open the app, and go to the "complex modifications" tab. then click "add rule". then click "import more rules from the internet". on the web site that opens, expand "Modifier Keys". import "Change caps_lock key".

that'll give you a rule to do what you want in karabiner. (the rule is "Change caps_lock to control if pressed with other keys, to escape if pressed alone".)

It’s in keyboard modifier keys.
that'll get you caps-as-control, but not caps-as-control-AND-escape (unless they've added that in high sierra, but I don't think so).
Ctrl-c can be used as esc in vim