Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One feature that is impossible to live without for me is Undo Tree. Unfortunately, the only editors that support it are Vim/Neovim and Emacs. I would love to switch to one of these modern editors, but not a single one of them supports this feature.


You don't get a visible tree representation, but JetBrains at least saves every change to your files regardless of how they were edited and whether any changes were reverted. It produces a flat list though, but you do get diffs and it works across all edited files, not just the current one (it's basically a built-in mini-VCS).

https://www.jetbrains.com/help/idea/local-history.html


EDIT: Actually, there is one more: https://fred-dev.tech/ But it's still deep in development, I'm keep an eye on how it turns out.


I'm writing an editor. Could you explain to me the use case? I looked it up and I don't exactly understand the reason besides it might be fun to look at

I really did not like that other editors would lose text if you pressed undo and type. The way my undo's work is if you type "a b c" and hit undo twice (so it's just "a") then type "d", then undo twice, it'll restore to "a b c"


Many times, I write a bunch of code before realising that a lot of it (but not all of it) is incorrect. At this point, being able to switch between two different points of history and selectively copy-paste the stuff that was correct is a godsend.

This is especially useful if you undid some operations, typed a little and then realised that you forgot to copy some important stuff that was strewn around in the old version.


That's one reason why I implemented it so it wouldn't lose information.

Hmm. I plan to implement a diff. The way I have it, you could copy the current source, hit undo to a version you want to compare again than use the clipboard as the version to diff with (vscode calls this "Compare Active File with Clipboard".) If you mess up you can still hit undo to go through all the previous edits you made since it's not lossy. Would this be as good for your usecase?


A tree is essentially a nice GUI on top of what you already have. It's allows me to visually click (or navigate) to a specific point of history, instead of remembering to hit Undo 15 times.


AFAIU, it also allows you to redo, even if you accidentally added a letter after undoing. That accidental edit then adds a branch to the tree instead of replacing all the redo entries.


Just a thought, do you want it as a tree? It seems like it'd make more sense if there was a bar or key you can press to go back and forward to the changes you want. I didn't really understand why having it as a tree was helpful.

I'm not going to say I wont implement it, I'm just saying I'm not understanding why you want it that specific way. Is the change you want always many minutes apart and why you want it as a tree? To find the one that happened many minutes before another? I know some people like how vscode has a timeline that says how many minutes/hours ago a change was, so they can pick it out


I type "A B C D". Then I undo thrice to get "A". Then I type to get "A E". And now I realise that what I actually want is "A E B D". My edits have created a branch is history. And I need to switch to the old branch and copy stuff twice (first "B" then "D"). That is why a tree is important.


I didn't heavily use undo trees so I don't remember how neovim/emacs displays it. I think I get it enough that if I try it out I'll be able to understand what you mean


If I understand correctly, this is the same as the default behaviour for Emacs (on top of which Undo Tree is implemented).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: