Hacker News new | ask | show | jobs
by mdonahoe 2562 days ago
inoremap jj <Esc>
3 comments

> 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 :/
Thanks! I'll check it out.
It works flawlessly :D
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?