twr_bw

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.

21 Responses
Add your response

111
A06c38dd3377bbc0db360c44a2969fed

Nice! Didn't know that was possible.

over 1 year ago ·
152
B7aaf37de0dd4c9384d15a61995f6b27

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
0dc69fc477295dd2209fd5ea5761b8b5

@originell Undo branches look amazing, thank you.

over 1 year ago ·
181
Cf0d817882a3a23592b7a83125ea3d3e

That is amazing!

over 1 year ago ·
186
B7aaf37de0dd4c9384d15a61995f6b27

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

over 1 year ago ·
192
Gavatar big

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

over 1 year ago ·
214
Why s

Great feature!

over 1 year ago ·
218
Me

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

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

over 1 year ago ·
220
0f8ded49793432a7eb610b35a7e3f3ec

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
98c5b03ee6a2786356748b9a99e0826f

@goblin Ctrl-R doesn't solve that?

over 1 year ago ·
1366
Default profile 1 normal

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
Default profile 1 normal

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
06237052745686cba3fcb34d056d3cad

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
0dc69fc477295dd2209fd5ea5761b8b5

@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
Joe cochran

This seriously just changed my life.

over 1 year ago ·
8709

Awesome!!

over 1 year ago ·
10468
E4c5a3861e057199b7f2e179b2ec5f8f

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

over 1 year ago ·
16840
Ea7e0e2b397c843bd1dc6f54d9cccc2e

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

over 1 year ago ·
17526
None

amazing! Thanks, man!

over 1 year ago ·
17993
A kcghsl normal

Amazing, Vim still manages to amaze me after using it for quite a while now.

over 1 year ago ·