5 ms·
The most productive mapping ever: imap jj <ESC>. No more having to reach for the escape key.
by Veritaas 11y ago
The most productive mapping ever: imap jj <ESC>.
No more having to reach for the escape key.
- zhengyi13 11y agoICBW, but I believe Ctrl-[ is already available, and works the same. For me, having remapped Capslock to Ctrl, this is a dead simple way of hitting Esc without going as far off homerow.
- leephillips 11y agoI had jk mapped for a long time and thought it was safe. Then one day I actually had to type it as text, and it took me a moment to figure out what was wrong. I'm retraining myself to use ^[ now.
- isbadawi 11y agoI don't think the speed hit you take when you actually have to type 'jk' should be a dealbreaker. It rarely comes up, and when it does, you can use e.g. '<C-v>j<C-v>k' or 'jjkak'.
- positr0n 11y agoEven better: imap jk <ESC> imap kj <ESC> I just hit both and j at the same time with my pointer and index fingers so it's essentially one keystroke.
- illamint 11y ago`kj` has worked really well for me (except, actually, when trying to write a blog post about a recent trip to Reykjavik, but that's the one time it's bitten me versus the shitton of time it's saved). I also have `zkj` mapped to `<ESC>:w<CR>` to save AND exit insert mode.
- thomasahle 11y agoHow does this work? What if you are in insert mode and actually want to type j or k?
- leephillips 11y agoIt's the combination jk (or kj) that is set up to switch from insert to normal mode. The idea is that this combination rarely occurs in English text. The drawbacks are a slight delay in cursor movement when typing j or k as vim waits to see what comes next, and momentary confusion when you inevitably need to actually insert these sequences.
- bcheung 11y agoMap Caps Lock to Ctrl. Then use Ctrl-C. You can keep your hand in home row.
- Fiahil 11y agoI have done something similar: I mapped Caps Lock to Esc on system-wide level, and it has been remarkable since. The only pitfall is when you start using someone else's computer and putting caps everywhere.
- unfortunately 11y agoI much prefer mapping Caps Lock to Escape at a different level (with xcape -- caps is both my i3 modifier and my Escape key). That way, when I SSH into something and use vim or a shell it still works (or when I vim as root), and anything with a vim mode will just work.