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 emulator.
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
…then add this to your
(key-chord-define evil-insert-state-map "jk" 'evil-normal-state)
Since @shosti pointed out that Evil considers deviation from Vim behavior as bugs, I filed a bug and one of the authors of Evil added a new possible value for
(setq evil-want-fine-undo 'fine)
With this setting, you get new undo units when moving the cursor in insert mode, but replace operations are undone in one step. As far as I can tell this is consistent with Vim. See here for details.
I used a highly customized vim, and now use an even more customized emacs. I think youll find every instance of keymapping in my keymapping config filehttps://github.com/mbriggs/.emacs.d/blob/master/init/init-keymaps.el
Keep in mind, I am rebinding stuff that real emacs users would consider heresy, so YMMV if you ever want to learn “real” emacs (I really don’t).
one thing I would recommend to any ex vimmer is this
;;; esc quits
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
so that esc actually quits pretty much anything (like pending prompts in the minibuffer)