Yes, vim’s “set undofile” will create a persistent undo file that stores all changes to the file indefinitely. You can undo changes made months ago over reboots. If you move the undo file between machines, you can undo on different computers.
Undoing a change from 2 hours ago in the same editing session is the trivial use case for undofile.
https://github.com/simnalamburt/vim-mundo