Using Evil for Good
So I use Vim as my primary editor. Unfortunately, some applications I require (e.g. Proof General) run only on the Emacs operation system, which comes with a terrible editor. Thankfully, I’ve found a pretty decent port of Vim to Emacs, called (appropriately) Evil.
Setting up Evil is quite easy:
- Download the evil pacakge to
~/.emacs.d/evil
:
1 2 |
cd ~/.emacs.d/
git clone git://gitorious.org/evil/evil.git evil
|
- Next, add a few lines to your .emacs file:
1 2 3 |
(add-to-list 'load-path "~/.emacs.d/evil/") (require 'evil) (evil-mode 1) |
- Now, customize. Evil doesn’t have ALL of Vim’s shortcuts by default. I’m not sure why. Here is what I added to .emacs for evil. It includes 2 other emacs plugins: evil-surround, which is a port of the vim surrounds plugin (necessary), and undo-tree, which provides fancy undo commands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
(add-to-list 'load-path "~/.emacs.d/evil/") (add-to-list 'load-path "~/.emacs.d/evil-surround/") (add-to-list 'load-path "~/.emacs.d/undo-tree") ;; Evil settings (setq evil-shift-width 2) (require 'evil) (evil-mode 1) (require 'surround) (global-surround-mode 1) (evil-ex-define-cmd "!" 'shell-command) ;;(evil-define-key 'normal proof-mode-map (kbd "M-v") 'proof-goto-point) (evil-define-key 'normal proof-mode-map (kbd "C-c RET") 'proof-goto-point) ;;; esc quits (define-key evil-normal-state-map [escape] 'keyboard-quit) (define-key evil-normal-state-map (kbd "C-u") '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) ;; Other things (define-key evil-normal-state-map "Y" 'copy-to-end-of-line) (global-set-key (kbd "RET") 'newline-and-indent) ;; coq (load-file "/usr/share/emacs/site-lisp/ProofGeneral/generic/proof-site.el") ;;(global-set-key (kbd "C-c RET") 'proof-goto-point) (evil-ex-define-cmd "[pr]prove" 'proof-goto-point) |
Here’s a link to someone’s very large Evil configuration file.