Hacker News new | ask | show | jobs
by positr0n 4038 days ago
Even 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.
2 comments

`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.
How does this work? What if you are in insert mode and actually want to type j or k?
It'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.