Live data from Hacker News

Text Editor Data Structures: Rethinking Undo

cdacamar.github.io

1–10 of 84 posts

Re: Text Editor Data Structures: Rethinking Undo

#2
I just skimmed it, but it looks like vim really has undo/redo "solved":

    - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!".
    - "g-" and "g+" eliminate the "orphaned redo".  They walk the entire undo/redo tree rather than just the linear undo/redo.
    - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock.  ":earlier 15 minutes" takes you to the code as it was 15 minutes ago.

Re: Text Editor Data Structures: Rethinking Undo

#3

I just skimmed it, but it looks like vim really has undo/redo "solved": - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!". - "g-" and "g+" eliminate the "orphaned redo". They walk the entire undo/redo tree rather than just the linear undo/redo. - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock. ":earlier 15 minutes" takes yo…

Don't forget about the Gundo plugin: it lets you navigate your tree of undo history.

Re: Text Editor Data Structures: Rethinking Undo

#4
Emacs undo-tree does everything I need. Emacs also supports undo in region which most editors don't seem to support and wasn't covered by the article.

I actually used regular Emacs undo for years which lets you get everywhere in the tree with a kind of tree traversal but you won't know where you are. I resisted undo-tree for ages but it's definitely worth it as it stays out of the way until the occasion you might need to use it.

Re: Text Editor Data Structures: Rethinking Undo

#5

I just skimmed it, but it looks like vim really has undo/redo "solved": - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!". - "g-" and "g+" eliminate the "orphaned redo". They walk the entire undo/redo tree rather than just the linear undo/redo. - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock. ":earlier 15 minutes" takes yo…

I love vim but I actually find undo/redo to be one of the few annoyances of the program, because of the whole linear undo/redo thing. So I guess I need to look into this g+ option…

Re: Text Editor Data Structures: Rethinking Undo

#6
Thinking about undo/redo is a great place to start thinking about your text editor's underlying data structure.

I went down this rabbit hole a while back. I had to really dig[1]: it's been 5 years...

---

Data structures aren't the only interesting rabbit-hole, though.

UI/UX doesn't get nearly as much attention as it deserves. There are really only two that I am aware of: Notepad and Vim. Vim's modal editing results in the user explicitly defining undo/redo points. You can even use the "." key to re-redo! Everything else essentially boils down to a greater or lesser version of Notepad: The user can't predict what state undo will take them to.

Something I have wanted to create for a long time (definitely more than 5 years) is a new modal editor. I don't want yet another vi clone: I want something that is defined from the ground up by user configuration. Maybe one of these days I will get far enough past the ADHD wall to make it happen...

[1] https://news.ycombinator.com/item?id=15381886

Re: Text Editor Data Structures: Rethinking Undo

#7

I just skimmed it, but it looks like vim really has undo/redo "solved": - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!". - "g-" and "g+" eliminate the "orphaned redo". They walk the entire undo/redo tree rather than just the linear undo/redo. - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock. ":earlier 15 minutes" takes yo…

I love vim but I actually find undo/redo to be one of the few annoyances of the program, because of the whole linear undo/redo thing. So I guess I need to look into this g+ option…

As I mentioned elsewhere, gundo is really helpful for navigating the undo tree.

My favorite thing about vim's flow is that it isn't just limited to undo/redo: you can re-perform your most recent action anywhere using the . key.

Re: Text Editor Data Structures: Rethinking Undo

#8

I just skimmed it, but it looks like vim really has undo/redo "solved": - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!". - "g-" and "g+" eliminate the "orphaned redo". They walk the entire undo/redo tree rather than just the linear undo/redo. - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock. ":earlier 15 minutes" takes yo…

Don't forget about the Gundo plugin: it lets you navigate your tree of undo history.

Gundo is great. There is also mundo, which is a fork of gundo. And, undotree, which doesn't require python support.

Re: Text Editor Data Structures: Rethinking Undo

#10

I just skimmed it, but it looks like vim really has undo/redo "solved": - Modal editing makes for nice "undo" points, clarifying whether undo should undo "World!" or "!". - "g-" and "g+" eliminate the "orphaned redo". They walk the entire undo/redo tree rather than just the linear undo/redo. - Time travel undo/redo is really handy when you want to go to where you were on the wall-clock. ":earlier 15 minutes" takes yo…

> ":earlier 15 minutes" takes you to the code as it was 15 minutes ago.

TIL. Very cool. tnx

Post reply on HN