top | item 47047632

(no title)

Lio | 12 days ago

It's not mentioned in the article but Vim (and NeoVim) keep undo/redo history in a tree rather than a simple linear timeline[1].

The practical usage is it's aways possible to get back to a previous state you were in, which is pretty neat.

e.g. You can undo 5 changes, try something else and decide that you prefered the text before you started undoing things. In most programs with a linear undo history you've wiped out your previous changes but not in Vim.

You can hop about the branches of the undo tree using the g+ and g- commands but it's much easier to add an undo tree visualiser plugin such as the venerable old Gundo[2].

1. https://neovim.io/doc/user/undo.html

2. https://docs.stevelosh.com/gundo.vim/

discuss

order

bradrn|12 days ago

Emacs has this too, with ‘undo-tree-mode’.

(Incidentally, the documentation is wonderful: ‘The only downside to this more advanced yet simpler undo system is that it was inspired by Vim. But, after all, most successful religions steal the best ideas from their competitors!’)

nothrabannosir|12 days ago

undo-tree-visualize is easily one of the biggest wow factors for unfamiliar users. Cannot unsee, cannot go back.

gmmachine|12 days ago

Strange, I love GNU screen, and find the key combinations very easy and intuitive. However, I could never seem to master GNU's Emacs and what I find are very strange default key commands. I love vim for the reason of, what I personally find, very intuitive key combinations.

I just downloaded VSCode for the first time recently -- which I was delighted to find has a VIM mode. From what I read VSCode's VIM mode does not respect the undo tree of actual VIM.

ghosty141|12 days ago

I had occasional problems with undo-tree (the tree broke occasionally), I've been using vundo for a while now and I'm a lot more happy with that.

sepeth|12 days ago

I haven’t been using Emacs for a long time now, but isn’t the Emacs way better? With undo tree you don’t lose any history, but the same is true for what Emacs does by default and it is much easier to navigate the history, since every change is part of a linear history and undos and redos also get added to it.

behnamoh|12 days ago

I use undo-tree plugin to use this in a nicer way. It's such a gem!

sodapopcan|12 days ago

I figured that this was what this article was going to be about.

embedding-shape|12 days ago

I thought so too, it's a part I've always struggled with effectively using, cause I get lost so quickly so was happy for a moment. But then reading the comments first, I got disappointed before I even had a chance to open the article.

boltzmann64|12 days ago

If you are going to need this, then you should use git instead of relying on the editor's undo tree.

Lio|12 days ago

You could if you remembered to make commits between every small, low value text edit. :P

Meanwhile the undo/redo tree is always there, ready to use and has no overhead. You can ignore it completely until you need it to save your arse.

sodapopcan|12 days ago

They are both useful. I'm a frequent committer but find myself using this, I wanna say, 0 - 3 times per month. It's one of those things that when you want it, you're really glad it exists.

Waterluvian|12 days ago

Consider this capability being used over the span of seconds as just another text editing tool. It would be like saying we don’t need undo/redo at all, just use git.