4 ms·
It's not mentioned in the article but Vim (and NeoVim) keep undo/redo history in a tree rather than a simple linear timeline[1]. The practical usage is it's aw
by Lio 8mo ago
It's not mentioned in the article but Vim (and NeoVim) keep undo/redo history in a tree rather than a simple linear timeline[1].
The practical usage is it's aways possible to get back to a previous state you were in, which is pretty neat.
e.g. You can undo 5 changes, try something else and decide that you prefered the text before you started undoing things. In most programs with a linear undo history you've wiped out your previous changes but not in Vim.
You can hop about the branches of the undo tree using the g+ and g- commands but it's much easier to add an undo tree visualiser plugin such as the venerable old Gundo[2].
1. https://neovim.io/doc/user/undo.html https://neovim.io/doc/user/undo.html
2. https://docs.stevelosh.com/gundo.vim/ https://docs.stevelosh.com/gundo.vim/
- bradrn 8mo agoEmacs has this too, with ‘undo-tree-mode’. (Incidentally, the documentation is wonderful: ‘The only downside to this more advanced yet simpler undo system is that it was inspired by Vim. But, after all, most successful religions steal the best ideas from their competitors!’)
- nothrabannosir 8mo agoundo-tree-visualize is easily one of the biggest wow factors for unfamiliar users. Cannot unsee, cannot go back.
- ghosty141 8mo agoI had occasional problems with undo-tree (the tree broke occasionally), I've been using vundo for a while now and I'm a lot more happy with that.
- nesarkvechnep 8mo agoThe mark and diff functionality is great too.
- scoops_ 8mo agoAnother day, another great Emacs package I’ve just learned about. This one’s going in the init.el for sure!
- sepeth 8mo agoI haven’t been using Emacs for a long time now, but isn’t the Emacs way better? With undo tree you don’t lose any history, but the same is true for what Emacs does by default and it is much easier to navigate the history, since every change is part of a linear history and undos and redos also get added to it.
- gmmachine 8mo agoStrange, I love GNU screen, and find the key combinations very easy and intuitive. However, I could never seem to master GNU's Emacs and what I find are very strange default key commands. I love vim for the reason of, what I personally find, very intuitive key combinations. I just downloaded VSCode for the first time recently -- which I was delighted to find has a VIM mode. From what I read VSCode's VIM mode does not respect the undo tree of actual VIM.
- noelwelsh 8mo agoA good number of Emacs users work with Vim key bindings. evil-mode is very good. I use Doom Emacs, which uses evil-mode by default.
- colpabar 8mo agofun fact: sublime text also has a vim mode (called "Vintage mode" which is just hilarious) that is built-in but disabled by default, rather than an extension like in vscode. vim keybinds are just the best.
- boltzmann64 8mo agoIf you are going to need this, then you should use git instead of relying on the editor's undo tree.
- sodapopcan 8mo agoThey are both useful. I'm a frequent committer but find myself using this, I wanna say, 0 - 3 times per month. It's one of those things that when you want it, you're really glad it exists.
- munk-a 8mo agoUndo is something that's extremely useful after the fact - commits can accomplish the same end if you're fastidious about continuously committing but fall short if you only realize your need after you've made the edit.
- Waterluvian 8mo agoConsider this capability being used over the span of seconds as just another text editing tool. It would be like saying we don’t need undo/redo at all, just use git.
- Lio 8mo agoYou could if you remembered to make commits between every small, low value text edit. :P Meanwhile the undo/redo tree is always there, ready to use and has no overhead. You can ignore it completely until you need it to save your arse.
- sodapopcan 8mo agoI figured that this was what this article was going to be about.
- embedding-shape 8mo agoI thought so too, it's a part I've always struggled with effectively using, cause I get lost so quickly so was happy for a moment. But then reading the comments first, I got disappointed before I even had a chance to open the article.
- sodapopcan 8mo agoI find it impossible to use without a plugin. I use https://github.com/mbbill/undotree https://github.com/mbbill/undotree and map it to `U` since I realized I never use `U` and it's easy to remember. https://github.com/sjl/gundo.vim/ https://github.com/sjl/gundo.vim/ is also popular but I like that the former is in pure vimscript (and the interface is a lil' better IMO).
- behnamoh 8mo agoI use undo-tree plugin to use this in a nicer way. It's such a gem!