4 ms·
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
by rcthompson 4y ago
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.
- rtpg 4y agoBecause it requires more than two commands
- gpvos 4y agoAnd it is exactly why I find Emacs undo so hard to work with. But maybe I will get it now I've read this article.
- tmtvl 4y agoYou can, if you like, install the 'vundo' package, which gives you a tree-based overview of your undo history, making it easy to switch between branches and go backward and forward. It's basically like the undo-tree view for the default undo mechanism.
- b3morales 4y agoTwo suggestions that might make it easier for you. There's a package called `undo-fu` that puts a thin layer on top of the undo system to keep the behavior strictly linear. And built in, there are the `undo-only` and `undo-redo` commands. Unlike the base `undo` they will only walk in one direction.
- BeetleB 4y agoNote that Emacs undo is not tree based, but works as described in the article. The tree based undo is a separate package one has to install.
- gpvos 4y agoAs I wrote.
- jonathannerat 4y agoSee `:h undo-persistance` for that feature. In particular you want to do `set undofile` in your vim config
- gpvos 4y agoI'm not sure how you deduced that I'm actually a vi user, but it's interesting to see that vim has similar support but using separate linear undo and redo commands g- and g+ . undo-persistance and undofile seem to be orthogonal to that though, I'm even less sure why you're bringing that up.
- onedognight 4y agoAdditionally, 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.
- nickcw 4y agoI did not know this, despite having used emacs for > 20 years - thank you!
- randlet 4y agoYes! 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?
- _huayra_ 4y agoWell if you want to return to Emacs, I can attest as a former long-time vim user that the emulation layers for vim modes in Emacs are fantastic! They're really the only good part of vim, as the configuration language was always a bit less desirable than elisp, imo.
- randlet 4y agoI've tried in past but always found the vim modes to be a bit lacking. My last attempt was probably 6 or 7 years ago though so maybe worth another shot!
- comfypotato 4y agoEvil mode is the modern standard I believe. Not a user myself, but I hear good things.
- fiddlerwoaroof 4y agoI ported my vim configuration to Evil Mode seven years ago and haven’t looked back. Evil Mode is the best done vi emulation layer I’ve seen and I think it even improves on vim in at least one area (the behavior of `I` in visual line mode).
- sulam 4y agoHe literally says why at the top of the post. People find it too complicated.
- taeric 4y agoI confess I didn't get that the post was about emacs. Reading the intro, it sounds more like it assumes nobody ever implemented something. And then goes on to describe what sounds a lot like how emacs works.
- db48x 4y agoThat’s the impression I got as well, since it never mentions Emacs at all and then describes exactly how Emacs works.
- 0xCMP 4y agoNo, he says most people do not actually implement the interface to make it make sense. So they have to make ctrl-z and ctrl-shift-z do the logical linear thing which requires all sorts of craziness which is what is complicated to do correctly (e.g. without breaking user expectations).
- fuckstick 4y agoNo they don’t. The method they are praising is already the base implementation for emacs.
- Chris2048 4y agoSounds like this solution would best be implemented with an undo-tree, but also a linear history mapping with pointers to that tree - the linear history would just log movement within the tree over time e.g. undo-redo would just be a backwards-forwards movement.
- rcthompson 4y agoThat's exactly what you get with undo-tree. The regular undo/redo commands continue working as normal, but you can also manually browse the tree if things get too nonlinear for you.
- Chris2048 4y agoThe one I saw had you browsing the tree, rather than a linear history representation of a tree.
- wging 4y agoYeah, I spent a long while (years) using pretty much exactly the solution he describes, as implemented in emacs. It's not as good as a tree, because undo/redo cycles make it very annoying to traverse through the history. I greatly prefer undo-tree.
- marcinreal 4y agoMake sure to check the value of `undo-limit`, as the low default value greatly (and needlessly, on modern machines) nerfs undo. It also applies to extensions like undo-tree and vundo I believe. > undo-limit is a variable defined in ‘C source code’. > Its value is 10000000 > Original value was 160000 Speaking of extensions, I find undo-tree pretty buggy. I might be one of a dozen people who actually love the default undo/redo mechanism.