How to map "jj" to Esc in emacs Evil mode

Solution 1:

This works for me. It requires the KeyChord library:

;;Exit insert mode by pressing j and then j quickly
(setq key-chord-two-keys-delay 0.5)
(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
(key-chord-mode 1)

It is inspired by @phils answer above and based on Simon's Coding Blog: Emacs and Unity Every Day.

Solution 2:

I don't know whether it works with Evil, but for Emacs in general the KeyChord library is designed for this sort of thing.

Try it and see?

(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)

Solution 3:

If you're using Spacemacs then I just found that this setting (added to the beginning of user-init) works very well,

(setq-default evil-escape-key-sequence "jj")