Time traveling in vim
Have you ever been using vim, and you mess up, hit u some number of times, and then you go too far?
You can get out of this by just using :earlier and :later.
For example :earlier 35s will go back 35 seconds in time. If you over shot your destination, you can move forward in time with :later 12s.
Related protips:
Written by Tobi Lehman
Related protips
20 Responses

Nice! Didn't know that was possible.

VIM has actually one of the most advanced history systems I know of. If you want to know more about VIM's undo-branches, just head over to the wiki -> http://vim.wikia.com/wiki/Using_undo_branches

@originell Undo branches look amazing, thank you.

That is amazing!

@tlehman always glad when I can amaze people with knowledge :D

I knew vim has crazy functionality, but wholy SH*T, awesome, thanks!

Great feature!

I use Gundo [1] for many of the history operations, very powerful.

Nice feature, but here's one scenario of undo that I still didn't solve:
Start up vim. Hit Insert, type two or three words, then press Ctrl-U. It'll delete the line you've just typed.
Can anyone tell me how to undo that and get the line back? :->
PS in bash and other readline-using thingies, I can sometimes use Ctrl-Y as the just-deleted line went to a buffer that Ctrl-Y then yanks. This doesn't work in vim though.

@goblin Ctrl-R doesn't solve that?

It does indeed not seem to be possible to undo Ctrl-U. The state you want to undo to does not seem to be saved as a leaf in the undo tree.

Umh, not just saved as a leaf, saved as a node.
I asked the question about Ctrl-U on IRC a while back and got a perfect response. See the first line, here: https://github.com/sharpsaw/vim-dots/blob/master/.vim/plugin/betterdefaults.vim

This is a very nice tips and tricks. But I am a bit curious that how do you use it in your workflow ?

@nxqd whenever I do something, then undo it several times, then go too far, then need to rewind the whole thing to get something back.

This seriously just changed my life.
Awesome!!

Every time I learn a new VIM feature I feel amazed, thanks for sharing! 👍

Wow, this is amazing, I always lose work by compulsively pressing U

amazing! Thanks, man!