Hacker News new | past | comments | ask | show | jobs | submit login

Alternative to escape in vi and vi-alikes: control-[

I recommend committing this to muscle memory. It takes two fingers, but is more comfortable than reaching for escape on most keyboards.

I prefer mapping caps lock to control rather than to escape, but that's another good alternative. But in any case it's nice to have another option for quitting vim in case something terrible has happened to your escape key, as it sometimes can (sigh) on modern laptops.




Also the Alt key + letter keys produces a series of key codes prefixed by escape, so one can use any single letter normal-mode command with the Alt key, resulting in "Escape"+<key>. This is convenient to quickly switch to e.g. moving the cursor with e.g. `Alt+j` to both escape from insert mode back to normal mode _and_ move down a line.


I knew about the Ctrl+[ but this might be a game changer... I have tried vim several times but have never gotten used to the idea of staying in one mode or another (emacs chords is more intuitive to me). This seems promising.


Another popular thing people like to do is map something like <k-j> or <j-j> to Escape. This can be easily done in your vimrc.

While the <Alt-[a-z]> mapping is great and enabled by default, it does have the side effect of logging an extra key press based on the [a-z].


Brilliant! If this was all I learned today, it would not be a wasted day. Thank you.


Map Caps Lock to both! Tap is Esc, hold is Ctrl.


I got that working with Karabiner Elements but how do people get this to work on Windows and Linux?


KMonad supports customisations like that. It's cross platform (macOS, Linux, Windows).

Though I use a fancy keyboard with QMK firmware, which allows customising this without needing to change settings on the computer.


I do it with xmodmap on Linux.


Did you change your username? I didn't realize that was an option.


Yes I did, and it probably wasn't really an option, but the moderators were kind enough to reclaim a very old, unused username (which I think was mine but forgot all the credentials to).


It's listed explicitly as an option in the FAQ.


What made you want to change it?


It's Stavros everywhere, it was only StavrosK here because the former was unavailable. I wasn't too fussed either way, but I asked the mods whether I could reclaim the username and they renamed the account to it, so here we are!

I figure it's easier for people to remember now.


ctrl+c also works if you are using vim (and not vi). one handed!


That is one-handed in precisely the same way that ctrl-[ is one-handed.


Not on a Mac, unfortunately. I mean, I can place my thumb on the left control and pinky on the [ so maybe you’re correct


My point was that if there's a CTRL key on each side of the keyboard, then anything involving a ctrl+something is one-handed-able.

Whether it's good typing practice to use one hand for both the ctrl and the C, say, in a ctrl-c construct - I can't say.

I know that I rarely if ever use the right-hand control or alt keys (on a standard US-mode PC keyboard that has alt and control keys on both sides). I suspect this is poor form.


Seconding this, especially if you have to SSH into remote or newly spun-up machines regularly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: