Hacker News new | ask | show | jobs
by intothemild 2562 days ago
Notice how all these have an esc key.

That should have been a hardware key!

A message from the Vim gang.

4 comments

As a member of the Vim gang, I have to say that using caps-lock is better anyway and MacOS has a built-in setting for it now, so go and fix that right away.

That said, I had a MBP with touch bar for half a year and even though I was quite excited when they announced it, I hated it. I will not buy another laptop with that thing on it.

As a member of the multilingual/multi-keyboard layout gang, Caps Lock is also the default button used to switch keyboard layouts.
I've been using caps lock as my control key for too long to make this leap. :-(
Karabiner Elements has this template where caps lock can behave as an esc key if you tap it, and a ctrl key if you hold it down.
Thanks! That sounds exactly like what I need, and I'm already using Karabiner.
You can also use it for both ctrl and esc with a little help by Hammerspoon (http://hammerspoon.org), e.g. I've been using this for the past year and it works great https://github.com/jasonrudolph/keyboard#a-more-useful-caps-...
Ctrl-[ homie. But I hear you.
If you have the UK keyboard on your Mac it has the wonderfully useless §± key top left next to the 1. Perfect for remapping to esc!
inoremap jj <Esc>
> inoremap jj <Esc>

That takes care of returning from insert mode to normal mode. What do you do for returning from other modes (operator pending mode, visual mode, etc.) to normal mode? I don't think it is possible to reliably reproduce all of the <Escape> in all the modes with remaps.

I didn't know "operator pending mode" was a thing, so I definitely don't use Esc to leave it.

For visual mode, apparently I just press v again. (I had to try it and see if I was subconsciously triggering Esc).

I had already weened myself off the Esc key, so the touchbar isn't that big a deal for me (though, i dont really ever use it). The terrible keyboard reliability is much worse, ugh.

Thanks for the reply.I have a follow up question about the "operator pending mode". I understand you didn't know it was a thing. But say, you press 'd' in normal mode because you want to delete a line and then you change your mind, what do you do it cancel the pressed 'd'?

I know I just rephrased the "operator pending mode" in a more elaborate manner but I am curious how you handle this case? Do you press Esc? Or do you go ahead with the delete anyway and then press 'u' to undo the delete? Or do you have some other technique to cancel the delete operator pending?

I think operator-pending is much less of a big deal when you can just finish the command and then hit "u" to undo it.

As for visual mode... I just noticed something odd: in Neovim, <Esc> doesn't drop me back into Normal mode from Visual or Block-visual; I have to hit "v" again. The behavior doesn't happen in Vim itself (that is, <Esc> works as expected.) I wonder why that is.

Either way, I'd hazard to say that exiting Insert mode is by far the most common use case for <Esc>... to the point where I really wouldn't even call it "escaping" in the sense of "bailing out of a mode early".

For everything else, I'd just remap Escape to Caps Lock at the system level and call it a day. But that's just me, and even though I think the Touch Bar is nifty, I definitely get where some folks' annoyance is coming from.

jk is better (TM) because it is a noop when already in normal mode :)

Also, pressing two different keys is faster than pressing the same key twice

Is it? djk in normal mode would delete the current line and move the cursor one line up!

d<Escape> on the other hand would cancel the operator-pending mode for delete and do nothing.

Is this why you didn't write "jk" at the end?
Remap CapsLock instead.
I did, it's my ctrl like anyone else that doesn't hate their pinky.
The next level is using Karabiner-Elements to map <caps> to <ctrl> when held and <esc> when tapped.
I usually do that but it stopped working for me on new macbook :/
This is what I have :) also right command + esdf for arrow keys
I do this. But then I find that whenever I have to help someone out at work in their Macbook, I have to go through the hassle of first mapping Caps Lock to Escape on their Mac, do the work, then remember to unmap it again after the helping session is over. Is there any good way to automate this workflow for helping other people on others' Mac?