Persist and Synchroize VIM Undo History Using Dropbox
It’s extremely useful to
- Have a virtually unlimited undo history, and
- Have it persisted even after exiting VIM, and
- Better, even have it synchronized across all your working machines using Dropbox.
Here is the .vimrc snippet I used to do the trick.
" Persist undo
"maximum number of changes that can be undone
"maximum number lines to save for undo on a buffer reload
" If have Dropbox installed, create a undo dir in it
silent !mkdir -p $HOME/Dropbox/.vimundo >/dev/null 2>&1
" Otherwise, keep them in home
silent !mkdir -p $HOME/.vimundo >/dev/null 2>&1
Note the double slash after the undodir, it tells VIM to name the undo file
using the full path of the editing file, so no naming collision will occur.