Thursday, March 3, 2011

Persistent undo with Vim 7.3

Persistent Undo -> You can do undo after save and quit, reopen later on a file.

Create a directory 'undodir' under your Vim's runtime path i.e ~/.vim
$ mkdir ~/.vim/undodir

Put below settings in your .vimrc file :
"================================
au BufWritePre /tmp/* setlocal noundofile
set undodir=~/.vim/undodir
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
"================================

Save .vimrc and quit.

Now open some text file do some changes in it, save and exit. Re-open the same file and press 'u' will undo your previous changes.

Happy Vimming !!

Thanks,
Satya

No comments:

Post a Comment

Followers