DEV Community

Sri Kadimisetty
Sri Kadimisetty

Posted on

Time travelling with Vim

Apart from a decent undotree, Vim also has the ability to revert the buffer state to an earlier time and that can come pretty handy sometimes because it's pretty awesome to think - "I wish I could just go back to how this was 5 minutes ago" and be able to do just that with :earlier 5m (m for minutes obviously).

It's not just minutes either, you can do seconds with s, hours with h, days with d and get this - "writes" with w. You can also just simply go back to an arbitrary n number of buffer states before; but just like writes, that's hard to keep track of mentally and instead you should probably use a proper plugin for that.

And yes, before you ask, you can indeed travel forward as well with :later 5m. Well that's all there is to it my friend; you are now capable of "time travelling". Cheers!!

Top comments (1)

Collapse
 
brandonwallace profile image
brandon_wallace

Vim is an amazing editor. Thanks for this post.
I use these options to undo changes to a file.

set undodir=~/.vim/backup
set undofile
set undoreload=10000
Enter fullscreen mode Exit fullscreen mode

Then I can press u to undo changes or R to reapply the changes.