summaryrefslogtreecommitdiffstats
path: root/content/posts/a-usable-vim-undo-tree.rst
blob: 931f30da05c151f0ca9efd4b6772e527e5a0c8e3 (plain)
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
35
A usable VIM Undo tree
##################################
:date: 2014-04-15 14:20
:tags: vim, undo


As some may have heard, vim stores your actions (and undos) as a tree, which is
great. With vim 7.3 there is even a option to persist these changes between
session. But with vanilla vim this tree is pretty much unusable. 

A friend showed me a great plugin which gives vim git-like super powers by
showing undos in a tree, together with a patch view with the `gundo plugin <https://github.com/sjl/gundo.vim>`_.

This plugin, together with persistent undo files feels almost like when i have used ctrl-r for the shell the first time! 

Configuration
-------------

Grab vundle for VIM, `install it
<https://github.com/gmarik/Vundle.vim>`_.

Add these lines to your vimrc:

.. code-block:: vim
    
    Bundle 'sjl/gundo.vim'
    nnoremap <F5> :GundoToggle<CR>
    set undodir=~/.vim/undo
    set undofile
    "maximum number of changes that can be undone
    set undolevels=1000000
    "maximum number lines to save for undo on a buffer reload
    set undoreload=10000000

In vim run **:BundleInstall** , you can now toggle the undo bar with **<F5>**.