This is exactly how undo works in Emacs out of the box. Personally, I prefer to install the undo-tree package and manually browse through the tree of undo paths. I'm not sure why this author finds a tree unacceptable for this purpose.
Additionally, emacs will filter undo/redo’s to changes within a region. If you select a region (no new command to learn) and use undo/redo, it will only perform those that affect text completely within the region. This is a superpower that delights me each time use it.
Resolving the great undo-redo quandary
91–100 of 247 posts
Re: Resolving the great undo-redo quandary
#92Sounds like the Braid version of undo-redo.
Could you elaborate or provide a link? I haven't heard of the "Braid version of undo-redo" before.
Re: Resolving the great undo-redo quandary
#93A -> B -> C -> rewound to B -> D -> E
Now at that E point, you'd want to have C too. (I'm assumikng there is no conflict between C and E.) There is no point in the linear history where you have both E and C. Sure you can go back to C, or go back to E. Or go back to C then decide to go back to E again. But you can't have both.
In vim, I use the fact that the yank buffers are not part of the undo/redo history, only changes to the file are. So I undo to the point I had the change I want back, yank them in a named buffer, redo and put the yanked buffer. You cannot go to an alternate history, but at least you can get back stuff you've deleted.
In git, what I describe is pretty-close to cherry-pick from a commit in a branch you deleted that you find using the ref-log.
Re: Resolving the great undo-redo quandary
#94Earlier quoted context omitted.
Vim stores all deleted text automatically, up to a max of 10, I think. Probably very possible to extend that with some advanced vimscripting.
Vim supports practically unlimited undo with branching history. You can visualize it and hop to any undo with a plugin. https://github.com/simnalamburt/vim-mundo
Sort of, anytime you delete something, that text gets stored somewhere in case, 2 hours later, you realised you wanted it.
Re: Resolving the great undo-redo quandary
#95The best form of history, undo and redo I've used is on hte various Jetbrains editors. It's a feature called Local History and is insanely useful. 1. It's always on. It never requires an explicit save or commit; 2. It automatically saves any changes and timestamps them; 3. You can view the state of a file or a tree at any moment in time and then pull out that file (or tree). 4. If you do that, it becomes part of the…
One point that is missing from your description is that it always shows the previous state in the diff view, which also feels really natural to use (I only sometimes whish the diff markers were more distinguishable from the inspection and ToDo markers).
Re: Resolving the great undo-redo quandary
#96This is exactly how undo works in Emacs out of the box. Personally, I prefer to install the undo-tree package and manually browse through the tree of undo paths. I'm not sure why this author finds a tree unacceptable for this purpose.
Additionally, emacs will filter undo/redo’s to changes within a region. If you select a region (no new command to learn) and use undo/redo, it will only perform those that affect text completely within the region. This is a superpower that delights me each time use it.
Re: Resolving the great undo-redo quandary
#97Earlier quoted context omitted.
Agreed. When I write "foobar", delete the last three characters (so that now I have "foo", then I write a "t", I would like to be able to undo the previous deletion (giving me "footbar"), not just adding the last character. Seems to me that would work especially well in editors that have the concept of verbs + objects, like vim's "delete until the end of the line" or "replace current word with...", but maybe it would…
Should it be “footbar”? Or “foobart”? I could see a case being made for either.
foo>>
I’m kidding, but only a bit: the (in hindsight, reasonable) lesson of the Pijul paper[1] is that if you want to do the most general merge and (therefore) avoid any arbitrary choices, you’re forced to extend your model from consistent files as sequences to files potentially containing conflicts as DAGs (or something even more complicated if you have data more complex than a single flat sequence or edits other than insertions). Or you can very carefully make a consistent set of arbitrary choices, like implementations of operational transformation usually do.Re: Resolving the great undo-redo quandary
#98Earlier quoted context omitted.
Additionally, emacs will filter undo/redo’s to changes within a region. If you select a region (no new command to learn) and use undo/redo, it will only perform those that affect text completely within the region. This is a superpower that delights me each time use it.
Yes! Having regional undo is super useful sometimes. I switched from emacs to vim a long time ago, but still miss this feature (although not enough to go searching to find an equivalent vim plug in I guess). Lazy web?
Re: Resolving the great undo-redo quandary
#99Earlier quoted context omitted.
I wish VS Code would expand on that feature, coming from IntelliJ. It's really annoying that you need to type the name of the file you want to see the local history of, even when it's the currently active file in the editor. There should be a sidebar widget for it that's active for whatever the current file is. The cool thing with IntelliJ is if you accidentally deleted a file you can just touch a blank version of th…
There is a sidebar widget. But it starts merged in the File Explorer view, and you need to drag it over from there to the sidebar to make it independent - https://stackoverflow.com/a/71522634 The widget is called "Timeline". > The cool thing with IntelliJ is if you accidentally deleted a file you can just touch a blank version of the file and the history comes back. Not sure if VS Code does that yet. VS Code does kee…
I think it's a fairly common situation that people using programming tools (VS Code, git, vim etc) can go for years without realizing there is a built-in feature that can solve exactly a problem they always struggled to solve. I'm not sure how to surface that sort of functionality in the tool, but I'm glad HN is here to point it out. One similarly cool thing I learned in a recent comment is that if you press dot (.) on Github web interface, it will launch an in-browser VS Code instance to edit the file you are viewing. Nifty!
Re: Resolving the great undo-redo quandary
#100> No, there is no undo "tree", nor any complicated graphical user interface to go with. ... You've got your undos, your redos, and that's it. The underlying data structure is strictly linear, but all edit states are preserved and reachable ... This is exactly how Emacs works! Emacs has worked like this since its beginning in 1980s. It was even documented in the first manual (1981): This might seem to pile one disaste…