Underrated Vim Option: undofile and undodir


A feature I enjoy using myself is not known to many users, as I found out last weekend. Besides undo with as many levels as you like, Vim also offers storing the undo information in a file. So you can exit Vim, reboot your computer and still undo changes you made. See the help for undofile.

– Bram Moolenaar (Vim maintainer)

If you use Neovim (and you should), just add set undofile to your init.vim.

Otherwise, add this to your vimrc:

" Keep undo history across sessions, by storing it in a file.
set undolevels=1000
if has('persistent_undo')
    silent !mkdir -p ~/.local/share/vim/undo > /dev/null 2>&1
    set undodir=~/.local/share/vim/undo
    set undofile
endif

Related Posts

hyperbolica

Random Thought: LC Theorem

I finally have an answer to "who's your favorite singer?"

My Top Tip for Helping People Get Started Programming

GPT-f

Random paper on angles

An Image is Worth 16x16 Words

Random stuff

Lossless Data Compression with Neural Networks by Fabrice Bellard

Downscaling Numerical Weather Models With GANs (My CI 2019 Paper)