title: How to change granularity level of undo in emacs evil-mode with undo-tree?
body: <p>These are some awesome options: emacs-24, evil-mode (using vim bindings in emacs), and undo-tree.</p>
  
  <p>However, when I'm in edit mode (insert mode), I sometimes jump around for a number inserts, deletes, etc. before hitting escape and leaving insert mode.</p>
  
  <p>"Undo" takes the whole insert (including deletes) as one edit. For example, I can't undo the paragraph I accidentally deleted without undo'ing the whole delete!</p>
  
  <p>Is there any way to fix this?</p>
  
  <p>Here are some related links:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6590889/how-emacs-determines-a-unit-of-work-to-undo">How Emacs determines a unit of work to undo</a></li>
  <li><a href="http://vim.wikia.com/wiki/Using_undo_branches" rel="noreferrer">http://vim.wikia.com/wiki/Using_undo_branches</a></li>
  <li><a href="http://vim.wikia.com/wiki/Modified_undo_behavior" rel="noreferrer">http://vim.wikia.com/wiki/Modified_undo_behavior</a></li>
  <li><a href="http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U" rel="noreferrer">This tip</a> probably has best explanation from the vim side.</li>
  </ul>
  
  <p>Here are the vim mappings that convert certain vim commands so that they can be undone:</p>
  
  <pre><code>inoremap &lt;c-u&gt; &lt;c-g&gt;u&lt;c-u&gt;
  inoremap &lt;c-w&gt; &lt;c-g&gt;u&lt;c-w&gt;
  inoremap &lt;End&gt; &lt;C-g&gt;u&lt;End&gt;
  inoremap &lt;BS&gt; &lt;c-g&gt;u&lt;BS&gt;
  inoremap &lt;CR&gt; &lt;c-g&gt;u&lt;CR&gt;
  inoremap &lt;del&gt; &lt;c-g&gt;u&lt;del&gt;
  </code></pre>
  
  <p>What is needed is for the undo mode inside of emacs evil undo-tree to track additional events besides just leaving insert mode. For example, you should be able to stay in insert mode a long time and then undo any sort of delete, cut, paste.</p>