twr_bw
Last Updated: December 07, 2018
·
20.53K
· tlehman

Time traveling in vim

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.

20 Responses
Add your response

111

Nice! Didn't know that was possible.

over 1 year ago ·
152

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

over 1 year ago ·
165

@originell Undo branches look amazing, thank you.

over 1 year ago ·
181

That is amazing!

over 1 year ago ·
186

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

over 1 year ago ·
192

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

over 1 year ago ·
214

Great feature!

over 1 year ago ·
218

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

[1] http://sjl.bitbucket.org/gundo.vim/

over 1 year ago ·
220

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.

over 1 year ago ·
296

@goblin Ctrl-R doesn't solve that?

over 1 year ago ·
1366

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.

over 1 year ago ·
1367

Umh, not just saved as a leaf, saved as a node.

over 1 year ago ·
1576

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

over 1 year ago ·
5913

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

over 1 year ago ·
5923

@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.

over 1 year ago ·
7758

This seriously just changed my life.

over 1 year ago ·
8709

Awesome!!

over 1 year ago ·
10468

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

over 1 year ago ·
16840

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

over 1 year ago ·
17526

amazing! Thanks, man!

over 1 year ago ·
Filed Under