Search code examples
emacseditoremacs23evil-mode

Evil Mode best practice?


I've been using Vim as my primary editor for years and tried Emacs several times during that time. Then I discovered Evil and decided that it meets my demand for speedy movement well enough that I can finally move on to Emacs.

So, to all you Evil users, how do you integrate it with normal Emacs functions? Have you encountered any conflicts between this mode and others? What's your sharing-worthy experiences/tips on this topic?


Solution

  • I used a highly customized vim, and now use an even more customized emacs. I think you'll find every instance of keymapping in my keymapping config file https://github.com/mbriggs/.emacs.d-oldv2/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
    (defun minibuffer-keyboard-quit ()
      "Abort recursive edit.
    In Delete Selection mode, if the mark is active, just deactivate it;
    then it takes a second \\[keyboard-quit] to abort the minibuffer."
      (interactive)
      (if (and delete-selection-mode transient-mark-mode mark-active)
          (setq deactivate-mark  t)
        (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
        (abort-recursive-edit)))
    (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)