Is there way to prevent Vim from clearing history after exiting Vim?
I want to be able to see the changes I made, while I am using Gundo (or UndoTree), even though I quit vim and the terminal and come back to the same file later on?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityIs there way to prevent Vim from clearing history after exiting Vim?
I want to be able to see the changes I made, while I am using Gundo (or UndoTree), even though I quit vim and the terminal and come back to the same file later on?
Use undotree
setting for this - :h undotree.txt
, :h undodir
and :h presistent_undo
.
I have it like so:
if has('persistent_undo')
if exists('$SUDO_USER')
" don't create root-owned files
set noundofile
else
set undodir=~/.local/tmp/vim/undo//
" keep undo files out of the way
set undodir+=~/.vim/tmp/undo//
set undodir+=.
" actually use undo files
set undofile
endif
endif
Despite the check for sudo user to not create a undo file owned by root, this sets few dirs for Vim to create undofile (first available will be used). Also this has set undofile
to make sure undofile will be used.
I just checked on some config file with UndoTree and there are changes made 11 days ago and I'm sure I did reboot my laptop in between at least 4 times.