HACKER Q&A
📣 pkkm

Why don't more programs have an undo tree?


Vim users take it for granted that if they undo a bunch of changes and then make a new change, they will just create a new branch in the undo history and the undone changes will be preserved. Emacs users frequently use the undo-tree package to get something similar. However, most text editors just drop the undone changes with no way to get them back, as do all the image editors I've used.

An undo tree seems like such an obvious improvement over a linear undo history that I'm wondering, why is this feature so uncommon? Is it much harder to implement than it looks?


  👤 johncoltrane Accepted Answer ✓
One simple reason would be that an undo tree is unusable without a way to visualize it, which is exactly what the various Vim and emacs plugins provide, and not that useful in practice anyway.

So you have to consider the cost of developing the underlying mechanism _and_ the UI and the benefits of working on a niche feature.


👤 n8henrie
Related -- for the last decade or so (neo)vim has been my primary editor, I'm probably an intermediate level user.

I have never really delved into the undo tree. I use `:earlier` and `:later` sometimes, but usually just a lot of undo / redo.

Does anyone have a good intro article they would recommend on how to get started? Preferably plugin-free (often using vim on bare bones machines, pis, fresh machines with minimal / no config, etc.).


👤 zikohh
Jetbrains have something that achieves the same as undo trees https://www.jetbrains.com/help/idea/local-history.html#resto... see the gif

But yes I wish it was the norm in all text editors.


👤 lern_too_spel
I prefer Emacs's default undo behavior to an undo tree. https://news.ycombinator.com/item?id=33560275

👤 amadeuspagel
Related question: Why are undo and version control separate features?

👤 tooltitude
Because it's too complicated for many users.