Mapping “jk” to Escape in Emacs’ evil-mode

[Origin]: http://blog.jenkster.com/2013/02/mapping-jk-in-emacs-evil-mode.html

I’m a Vim user. But more & more these days I find that one of my favourite versions of Vim is Emacs. Specifically, its evil-mode package, which is a very good Vim emulator1.

If you get started with evil-mode, one of the first questions you might ask is, “How do I remap ESC to something more finger-friendly?” Some people like to map jj. Personally I like jk, because it rolls off the fingers a little more easily.

Anyway, there are a couple of ways to do it in Emacs. The simplest & cleanest I’ve found is to install the key-chord package:

M-x package-install
key-chord

…then add this to your .emacs file:

(require 'key-chord)
(key-chord-mode 1)
(key-chord-define evil-insert-state-map  "jk" 'evil-normal-state)

Easy.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s