Difference between revisions of "Evil"

From WikEmacs
Jump to: navigation, search
(ZPnHhwzpGxXpwIWeT)
(save on exit mode hook)
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
zlib包shell> ./configure --prefix=/usr/local/zlibshell> make checkshell> make inltsal libpng包 支持PNG shell> ./configure --prefix=/usr/local/libpngshell> makeshell> make inltsal jpeg-6b包 支持jpg格式 shell> ./configure --prefix=/usr/local/jpeg-6b --enable-share --enable-staticshell> make testshell> makeshell> make inltsalshell> make inltsal-lib freetype包 字体支持 shell> ./configure --prefix=/usr/local/freetypeshell> makeshell> make inltsal 最后安装gd包shell> ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg-6b --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetypeshell> makeshell> make inltsal
+
'''Evil''' is an '''e'''xtensible '''vi''' '''l'''ayer for Emacs. It provides Vim features like Visual selection and text objects, and is the successor to the now defunct vimpulse and vim-mode.
 +
 
 +
=== Quick install ===
 +
 
 +
Evil comes prebuilt in emacs24.
 +
In Emacs23, Evil can be downloaded and installed using [[el-get]] with: M-x el-get-install RET evil RET.
 +
 
 +
=== Download ===
 +
 
 +
Alternatively, Evil lives in a Git repository. To download Evil, do:
 +
 
 +
git clone git://gitorious.org/evil/evil.git
 +
 
 +
If you don't have Git, just head over to [https://gitorious.org/evil/evil/commits/master Gitorious] and click the ''"Download master as tar.gz"'' link (extract with ##tar -xzf master.tar.gz##).
 +
 
 +
=== Install ===
 +
 
 +
If you installed it manually, move Evil to ~/.emacs.d/evil (or somewhere else in your ##load-path##).
 +
In any case, add the following lines to ~/.emacs:
 +
 
 +
(add-to-list 'load-path "~/.emacs.d/evil") ;;no need with 24
 +
(require 'evil)
 +
(evil-mode 1)
 +
 
 +
 
 +
Evil requires [UndoTree undo-tree.el] in the load-path for linear undo and undo branches. Otherwise, Evil uses regular Emacs undo.
 +
 
 +
=== Documentation ===
 +
 
 +
A brief [https://gitorious.org/evil/evil/blobs/raw/doc/doc/evil.pdf PDF manual] is available in the /doc subdirectory.
 +
 
 +
=== Configuration ===
 +
 
 +
One thing I would recommend to any ex vimmer is to make  escape to quit actually pretty much anything (like pending prompts in the minibuffer):
 +
 
 +
    ;;; 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)
 +
 
 +
The following makes you loose vim commands, but gives you back basic emacs commands, like C-y to paste in insert mode or C-r to search backward:
 +
 
 +
    (define-key evil-normal-state-map "\C-y" 'yank)
 +
    (define-key evil-insert-state-map "\C-y" 'yank)
 +
    (define-key evil-visual-state-map "\C-y" 'yank)
 +
    (define-key evil-insert-state-map "\C-e" 'end-of-line)
 +
    (define-key evil-normal-state-map "\C-w" 'evil-delete)
 +
    (define-key evil-insert-state-map "\C-w" 'evil-delete)
 +
    (define-key evil-insert-state-map "\C-r" 'search-backward)
 +
    (define-key evil-visual-state-map "\C-w" 'evil-delete)
 +
 
 +
 
 +
In insert mode, Evil uses linear undo. If you want fine grain undo:
 +
 
 +
    (setq evil-want-fine-undo t)
 +
 
 +
but remember, we shouldn't stay long in insert mode.
 +
 
 +
If you'd like to type jj or jk in insert mode to go back to normal mode, you may use [[key-chord]]:
 +
 
 +
    (key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
 +
 
 +
'''Note''': I still load evil with M-x, I didn't set (evil-mode 1), so in order to tweak keybindings I had to enclose them in a hook, so that my config is called when evil is called:
 +
 
 +
    (add-hook 'evil-after-load-hook
 +
          (lambda ()
 +
          ;; config
 +
    ))
 +
 
 +
==== Hooks ====
 +
 
 +
There are some hooks that allow to do things when we enter or exit a mode (see the pdf manual).
 +
 
 +
For example, to save the buffer when we exit the insert mode:
 +
    (add-hook 'evil-insert-state-exit-hook 'save-buffer)
 +
 
 +
=== Articles ===
 +
 
 +
* [http://dnquark.com/blog/2012/02/emacs-evil-ecumenicalism/ Emacs Evil Ecumenicalism]
 +
 
 +
=== Plug-ins ===
 +
 
 +
* [https://github.com/timcharper/evil-surround evil-surround]: Port of Vim's surround script.
 +
 
 +
* [https://github.com/cofi/evil-numbers evil-numbers]: Vim-like increment and decrement.
 +
 
 +
* [https://github.com/cofi/evil-leader evil-leader]: Port of Vim's mapleader.
 +
 
 +
* [[ace-jump]]: Port of Vim's Easy-motion
 +
 
 +
=== Bug tracker ===
 +
 
 +
The bugtrucker can be found on [https://bitbucket.org/lyro/evil/issues?status=new&status=open Bitbucket].
 +
[[Category:Vi User]] [[Category:Vim User]]

Revision as of 10:26, 20 August 2013

Evil is an extensible vi layer for Emacs. It provides Vim features like Visual selection and text objects, and is the successor to the now defunct vimpulse and vim-mode.

Quick install

Evil comes prebuilt in emacs24. In Emacs23, Evil can be downloaded and installed using el-get with: M-x el-get-install RET evil RET.

Download

Alternatively, Evil lives in a Git repository. To download Evil, do:

git clone git://gitorious.org/evil/evil.git

If you don't have Git, just head over to Gitorious and click the "Download master as tar.gz" link (extract with ##tar -xzf master.tar.gz##).

Install

If you installed it manually, move Evil to ~/.emacs.d/evil (or somewhere else in your ##load-path##). In any case, add the following lines to ~/.emacs:

(add-to-list 'load-path "~/.emacs.d/evil") ;;no need with 24
(require 'evil)
(evil-mode 1)


Evil requires [UndoTree undo-tree.el] in the load-path for linear undo and undo branches. Otherwise, Evil uses regular Emacs undo.

Documentation

A brief PDF manual is available in the /doc subdirectory.

Configuration

One thing I would recommend to any ex vimmer is to make escape to quit actually pretty much anything (like pending prompts in the minibuffer):

   ;;; 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)

The following makes you loose vim commands, but gives you back basic emacs commands, like C-y to paste in insert mode or C-r to search backward:

   (define-key evil-normal-state-map "\C-y" 'yank)
   (define-key evil-insert-state-map "\C-y" 'yank)
   (define-key evil-visual-state-map "\C-y" 'yank)
   (define-key evil-insert-state-map "\C-e" 'end-of-line)
   (define-key evil-normal-state-map "\C-w" 'evil-delete)
   (define-key evil-insert-state-map "\C-w" 'evil-delete)
   (define-key evil-insert-state-map "\C-r" 'search-backward)
   (define-key evil-visual-state-map "\C-w" 'evil-delete)


In insert mode, Evil uses linear undo. If you want fine grain undo:

   (setq evil-want-fine-undo t)

but remember, we shouldn't stay long in insert mode.

If you'd like to type jj or jk in insert mode to go back to normal mode, you may use key-chord:

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

Note: I still load evil with M-x, I didn't set (evil-mode 1), so in order to tweak keybindings I had to enclose them in a hook, so that my config is called when evil is called:

   (add-hook 'evil-after-load-hook
         (lambda ()
         ;; config
    ))

Hooks

There are some hooks that allow to do things when we enter or exit a mode (see the pdf manual).

For example, to save the buffer when we exit the insert mode:

   (add-hook 'evil-insert-state-exit-hook 'save-buffer)

Articles

Plug-ins

Bug tracker

The bugtrucker can be found on Bitbucket.