by _mlxl · 7y ago · 0 comments
If you put the commands:
set undofile
set undodir=~/.vim/undodir
You get infinite undo in your files.Now when you go into a file, delete or add some text and close your terminal down, the next time you enter vim you can (re|un)do previous operations.
Has saved my ass more times than I care to mention over my career!
let s:undos = split(globpath(&undodir, '*'), "\n")
call filter(s:undos, 'getftime(v:val) < localtime() - (60 * 60 * 24 * 90)')
call map(s:undos, 'delete(v:val)')I understand why developers don't have it on by default in other text editors (space) but seeing as I don't fill my HDD with movies or games or any other large media like that, i've got all the space in the world.
if !isdirectory($HOME . "/.vim/undodir")
call mkdir($HOME . "/.vim/undodir", "p")
endif
set undofile
set undodir=~/.vim/undodir