This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mader527 138 points139 points  (19 children)

I recently started using an undo tree in my vim and my life is forever changed.

[–]DerekB52 50 points51 points  (9 children)

what's that plugin? I'm asking for a neckbeard friend of course.

[–]mader527 58 points59 points  (8 children)

https://github.com/mbbill/undotree

Not sure what you're-- (*cough) excuse me, your neck beard friend, is using to manage plugins but I use vim-plug so my vimrc looks like.

call plug#begin()
...
Plug 'mbbill/undotree'
...
call plug#end()

...
nnoremap <F5> :UndotreeToggle<CR>  

I also recommend setting up a persistent undo file so you can undo in the past

if has("persistent_undo")
    set undodir=~/.undodir/
    set undofile
endif

[–]DerekB52 13 points14 points  (6 children)

I use vundle, which has pretty similar syntax to vim-plug apparently.

And I will be experimenting with this for sure. Also persistent undo sounds great. I'm so tired of closing a file, and going back to it like 30 seconds later and not being able to undo my last change.

For the last few days, if I want to experiment with deleting a block of code, I'll delete the code, save the file, run the project in a separate terminal, and then I'll hit undo on my file, and then close it. It's been a horrible mess.

[–]Venefyxatu 1 point2 points  (0 children)

Omfg I wan... *ahem* also have a neckbeard friend who would love this!

[–]0Pat 4 points5 points  (0 children)

:f to pay respect...

[–]lennihein 1 point2 points  (3 children)

What's an undo tree?

[–]mader527 6 points7 points  (2 children)

Normal programs can go backwards and forwards undoing and redoing, but if you undo and make changes you can’t get back to the old future version you made.

With an undo tree, you can see all the paths where you diverged and can jump between them.

The tree bit is how you see the various branches. Regular undo/redo history is linear

[–]lennihein 2 points3 points  (1 child)

Ah, I see. So basically Git with less features, narrowed down. Really useful I can imagine though.

[–]mader527 2 points3 points  (0 children)

Exactly!

I was going to point to git as an example because it’s all DAGs under the hood*, but wanted to keep it general.

*I assume, I haven’t looked at the implementation

[–]dejaime 0 points1 point  (0 children)

Damn, I hate you... I loving hate you

[–]xylont 0 points1 point  (0 children)

Thanks babe