← til

Discovering Neovim undofiles

22 Dec, 2025
neovim

I was today years old when I discovered that you can have peristent undo/redo history in neovim:

-- in ~/.config/nvim/init.lua

-- Enable persistent undo
vim.opt.undofile = true
-- Store undo history in ~/.local/share/nvim/undo
vim.opt.undodir = vim.fn.stdpath("data") .. "/undo"

With this neovim “remembers” all your changes even if you close the editor and then reopen the file.