<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikemacs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=128.199.91.69</id>
	<title>WikEmacs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wikemacs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=128.199.91.69"/>
	<link rel="alternate" type="text/html" href="https://wikemacs.org/wiki/Special:Contributions/128.199.91.69"/>
	<updated>2026-04-12T21:34:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wikemacs.org/index.php?title=Evil&amp;diff=47160</id>
		<title>Evil</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Evil&amp;diff=47160"/>
		<updated>2015-11-07T00:32:24Z</updated>

		<summary type="html">&lt;p&gt;128.199.91.69: Evil is on bitbucket.org now&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''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.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
&lt;br /&gt;
Evil can be downloaded and installed using [[el-get]] with: {{Command|el-get-install RET evil RET}}, or using [[Melpa]] with {{Command|package-install RET evil RET}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Manual install ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Alternatively, Evil lives in a Mercurial repository. To download Evil, do:&lt;br /&gt;
&lt;br /&gt;
 hg clone https://bitbucket.org/lyro/evil&lt;br /&gt;
&lt;br /&gt;
If you don't have Mercurial, you can download Evil here: https://bitbucket.org/lyro/evil/get/default.zip&lt;br /&gt;
&lt;br /&gt;
If you installed it manually, move Evil to {{Filename|~/.emacs.d/evil}} (or somewhere else in your load-path). &lt;br /&gt;
In any case, add the following lines to ~/.emacs:&lt;br /&gt;
&lt;br /&gt;
 (add-to-list 'load-path &amp;quot;~/.emacs.d/evil&amp;quot;) ;;no need with 24&lt;br /&gt;
 (require 'evil)&lt;br /&gt;
 (evil-mode 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Evil requires [[UndoTree]] in the load-path for linear undo and undo branches. Otherwise, Evil uses regular Emacs undo.&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
A brief [https://bytebucket.org/lyro/evil/raw/default/doc/evil.pdf PDF manual] is available in the /doc subdirectory.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
For those not familiar with vim, here's a quick summary of useful commands.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Tip:''': to see a full list of commands available in the current mode, install ''help-fns+'' with [[ELPA]], require it (see its doc). Now you can type '''C-h M-k'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To enter '''insert''' state: try out '''i a o''' and the upper-case ones;&lt;br /&gt;
&lt;br /&gt;
To delete chars, words and lines use '''x''', the usual '''d''' followed by a word or a movement ('''$''' is end of line, '''^''' the beginning), '''dd''' and '''D''', or replace an object with '''c''' ;&lt;br /&gt;
&lt;br /&gt;
Copy and paste: '''y Y p P''' ;&lt;br /&gt;
&lt;br /&gt;
To navigate around the buffer, in normal mode, use '''e E w W b B t T f F ( ) { }''' and '''j k h l - + &amp;lt;RET&amp;gt; &amp;lt;backspace&amp;gt; &amp;lt;space&amp;gt;'''; &lt;br /&gt;
Go to beginning and end of buffer with '''gg''' and '''G'''; &lt;br /&gt;
&lt;br /&gt;
Cycle between cursor position: double backquotes, '''C-i''' and '''C-o''';&lt;br /&gt;
&lt;br /&gt;
To navigate around the screen, use '''H L M''' to go to the Highest/Lowest/Middle line of the screen;&lt;br /&gt;
&lt;br /&gt;
Search forward and backward with '''/''' and '''?''', use '''n''' and '''N''' to go to the next and previous occurence;&lt;br /&gt;
&lt;br /&gt;
Go to the next or previous occurence of token under point with '''*''' or '''#''' ;&lt;br /&gt;
&lt;br /&gt;
Select a region with '''v''' or '''V''', use '''vi''' and '''&amp;quot;''', '''(''' or '''[''' to select what's inside them and re-select the last region selected with '''gv'''. Again with text objects, type '''ci(''' when you are inside brackets to replace all that is inside them.&lt;br /&gt;
&lt;br /&gt;
Go to the '''definition of the symbol''' under point with '''gd''' ;&lt;br /&gt;
&lt;br /&gt;
Indent the line or region with '''&amp;lt;''' and '''&amp;gt;''' ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some more:&lt;br /&gt;
&lt;br /&gt;
Join lines with '''J''' &lt;br /&gt;
&lt;br /&gt;
Set a mark with '''m&amp;lt;char&amp;gt;''', go to a mark with backquote + &amp;lt;char&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Code folding''' with '''za''' (toggle), '''zc''' (close), '''zm''' and '''zr''' (close and open all)&lt;br /&gt;
&lt;br /&gt;
Move the current line at the center, bottom and top of screen: '''zz''', '''zb''' and '''zt''' (C-l with emacs)&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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):&lt;br /&gt;
&lt;br /&gt;
    ;;; esc quits&lt;br /&gt;
    (define-key evil-normal-state-map [escape] 'keyboard-quit)&lt;br /&gt;
    (define-key evil-visual-state-map [escape] 'keyboard-quit)&lt;br /&gt;
    (define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)&lt;br /&gt;
    (define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)&lt;br /&gt;
    (define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)&lt;br /&gt;
    (define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)&lt;br /&gt;
    (define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)&lt;br /&gt;
&lt;br /&gt;
The following makes you lose vim commands, but gives you back basic emacs commands, like C-y to paste in insert mode or C-r to search backward:&lt;br /&gt;
&lt;br /&gt;
    (define-key evil-normal-state-map &amp;quot;\C-y&amp;quot; 'yank)&lt;br /&gt;
    (define-key evil-insert-state-map &amp;quot;\C-y&amp;quot; 'yank)&lt;br /&gt;
    (define-key evil-visual-state-map &amp;quot;\C-y&amp;quot; 'yank)&lt;br /&gt;
    (define-key evil-insert-state-map &amp;quot;\C-e&amp;quot; 'end-of-line)&lt;br /&gt;
    (define-key evil-normal-state-map &amp;quot;\C-w&amp;quot; 'evil-delete)&lt;br /&gt;
    (define-key evil-insert-state-map &amp;quot;\C-w&amp;quot; 'evil-delete)&lt;br /&gt;
    (define-key evil-insert-state-map &amp;quot;\C-r&amp;quot; 'search-backward)&lt;br /&gt;
    (define-key evil-visual-state-map &amp;quot;\C-w&amp;quot; 'evil-delete)&lt;br /&gt;
&lt;br /&gt;
== Use fine grain undo ==&lt;br /&gt;
&lt;br /&gt;
In insert mode, Evil uses linear undo. If you want fine grain undo:&lt;br /&gt;
&lt;br /&gt;
    (setq evil-want-fine-undo t)&lt;br /&gt;
&lt;br /&gt;
but remember, we shouldn't stay long in insert mode.&lt;br /&gt;
&lt;br /&gt;
== Use keychords to go back to normal mode ==&lt;br /&gt;
&lt;br /&gt;
If you'd like to type jj or jk in insert mode to go back to normal mode, you may use [[key-chord]]:&lt;br /&gt;
&lt;br /&gt;
    (key-chord-define evil-insert-state-map &amp;quot;jj&amp;quot; 'evil-normal-state)&lt;br /&gt;
&lt;br /&gt;
== Load config only when we call evil-mode ==&lt;br /&gt;
&lt;br /&gt;
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 and not at startup:&lt;br /&gt;
&lt;br /&gt;
    (add-hook 'evil-after-load-hook&lt;br /&gt;
          (lambda ()&lt;br /&gt;
          ;; config&lt;br /&gt;
     ))&lt;br /&gt;
&lt;br /&gt;
== Hooks ==&lt;br /&gt;
&lt;br /&gt;
There are some hooks that allow to do things when we enter or exit a mode (see the pdf manual).&lt;br /&gt;
&lt;br /&gt;
For example, to save the buffer when we exit the insert mode:&lt;br /&gt;
&lt;br /&gt;
    (defun my-save-if-bufferfilename ()&lt;br /&gt;
      (if (buffer-file-name)&lt;br /&gt;
          (progn&lt;br /&gt;
            (save-buffer)&lt;br /&gt;
            )&lt;br /&gt;
        (message &amp;quot;no file is associated to this buffer: do nothing&amp;quot;)&lt;br /&gt;
        )&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    (add-hook 'evil-insert-state-exit-hook 'my-save-if-bufferfilename)&lt;br /&gt;
&lt;br /&gt;
== Enter an emacs mode in a given state ==&lt;br /&gt;
&lt;br /&gt;
There are some situations where you don't want to be in normal mode by default. For example, it's more useful to be in insert mode when we enter a magit commit buffer, or maybe you prefer to be in emacs mode in a dired buffer.&lt;br /&gt;
&lt;br /&gt;
For that purpose, evil provides the '''evil-set-initial-state''' command (see part 2.2 of the pdf documentation) that we can use like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(evil-set-initial-state 'git-commit-mode 'insert) ;; enter insert mode to edit a commit message&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is a handy loop to define more at once:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
    (loop for (mode . state) in '((inferior-emacs-lisp-mode . emacs)&lt;br /&gt;
                              (nrepl-mode . insert)&lt;br /&gt;
                              (pylookup-mode . emacs)&lt;br /&gt;
                              (comint-mode . normal)&lt;br /&gt;
                              (shell-mode . insert)&lt;br /&gt;
                              (git-commit-mode . insert)&lt;br /&gt;
                              (git-rebase-mode . emacs)&lt;br /&gt;
                              (term-mode . emacs)&lt;br /&gt;
                              (help-mode . emacs)&lt;br /&gt;
                              (helm-grep-mode . emacs)&lt;br /&gt;
                              (grep-mode . emacs)&lt;br /&gt;
                              (bc-menu-mode . emacs)&lt;br /&gt;
                              (magit-branch-manager-mode . emacs)&lt;br /&gt;
                              (rdictcc-buffer-mode . emacs)&lt;br /&gt;
                              (dired-mode . emacs)&lt;br /&gt;
                              (wdired-mode . normal))&lt;br /&gt;
      do (evil-set-initial-state mode state))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
== Articles ==&lt;br /&gt;
&lt;br /&gt;
* [http://dnquark.com/blog/2012/02/emacs-evil-ecumenicalism/ Emacs Evil Ecumenicalism]&lt;br /&gt;
&lt;br /&gt;
== Plug-ins ==&lt;br /&gt;
&lt;br /&gt;
* [[ace-jump]]: Port of Vim's Easy-motion: jump to any character in the buffer with 3 keystrokes.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/timcharper/evil-surround evil-surround]: Port of Vim's surround script.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/cofi/evil-numbers evil-numbers]: Vim-like increment and decrement.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/cofi/evil-leader evil-leader]: Port of Vim's mapleader.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/edwtjo/evil-org-mode evil-org-mode]: Supplemental evil-mode key-bindings to Emacs org-mode.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/krisajenkins/evil-tabs evil-tabs]: for when you type &amp;lt;code&amp;gt;:tabnew&amp;lt;/code&amp;gt; and nothing happens.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/raugturi/powerline-evil powerline-evil]: Utilities for better Evil support for Powerline.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Dewdrops/evil-exchange evil-exchange]: a port of vim-exchange&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/gridaphobe/evil-god-state evil-god-state]: an evil-mode state for using god-mode.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/cofi/evil-leader evil-leader]: &amp;lt;leader&amp;gt; key for evil&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/roman/evil-paredit evil-paredit]: integration to paredit&lt;br /&gt;
&lt;br /&gt;
* [http://melpa.milkbox.net/#/evil-visualstar evil-visualstar]: make a visual selection and search it.&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/gabesoft/evil-mc evil-mc]: easy multiple cursors&lt;br /&gt;
&lt;br /&gt;
* [http://melpa.org/#/evil-jumper evil-jumper]: jump accross buffer boundaries&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/hlissner/evil-snipe evil-snipe]: a port of [https://github.com/justinmk/vim-sneak vim-sneak]/[https://github.com/goldfeld/vim-seek vim-seek]; 2-char searching&lt;br /&gt;
&lt;br /&gt;
search for all plugins in [http://melpa.milkbox.net/#/ the melpa page].&lt;br /&gt;
&lt;br /&gt;
== Bug tracker ==&lt;br /&gt;
&lt;br /&gt;
The bugtrucker can be found on [https://bitbucket.org/lyro/evil/issues?status=new&amp;amp;status=open Bitbucket].&lt;br /&gt;
[[Category:Vi User]] [[Category:Vim User]]&lt;/div&gt;</summary>
		<author><name>128.199.91.69</name></author>
	</entry>
</feed>