day macha
Rebinding the Escape key in Vim: the k j approach

As using vim involves switching between command and insert mode a lot, you end up reaching for the Escape key often—too often for my fingers.

You change your Escape key for Caps Lock. I was using C-c for the Escape key, which is a default alternative in vim. C-[ appears to be a old time short-cut, too.

But they all suffer from the same problems: moving your fingers away from the home row, and holding down the Ctl key in two of the approaches. And I hate doing both those things.

I stumbled across this excellent solution on a forum recently though:

:imap kj <ESC>

Yes. This maps the kj key combination, in insert mode, to the Escape key. This works surprising well, too.

The k and j combination hardly ever comes up—none so far in a day’s worth of typing—in the English language. And they’re both on the home row.

It’s made vim so much nicer.

Blog comments powered by Disqus