tms9918 · 2022-10-23 01:38
I often edit a line, edit at a different place in the same file, and then wish I could bring the former line back
jalihal · 2022-10-23 01:48
You can `undo` in a region. Take a look at the manual on undoing changes.
mmaug · 2022-10-23 02:11
Select a region and undo. It will undo all changes one-by-one between mark and point of the region
tms9918 · 2022-10-23 03:39
How did I miss this! Awesome, thanks!
dirtycimments · 2022-10-23 13:53
Today I learn!
FrozenOnPluto · 2022-10-23 15:25
I've been using Emac for probably 30 years and did not know this :)
terminal_cope · 2022-10-23 15:27
yeah, I stumbled upon this about a year ago, after 28 years... I still never remember it exists when it would be useful :(. Perhaps after this reminder...
snackematician · 2022-10-23 16:15
I love undo-in-region (aka "selective undo")! And I wish more people knew about it, I regard it as one of Emacs' killer features.
In the past, I used undo-tree.el, but occasionally suffered from bugs that would cause me to lose work. After learning about undo-in-region, I switched back to native Emacs undo, and am very satisfied.
I mainly used undo-tree to search the undo history for old edits to copy back in; but it's much more effective to just select the region where the old change was, and undo in that region only.
Then, if I need to get back to the state before undo'ing, just use revert-buffer (which also plays nicely with native undo [1]).
[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Undo.html
eleven_cupfuls · 2022-10-23 18:32
If you still want undo visualization, there's vundo that gives you a tree display of the state of the built-in undo: https://github.com/casouri/vundo
artyhedgehog · 2022-10-23 23:40
How on Earth is this even possible?! Emacs never fails to surprise...
mmaug · 2022-10-24 00:22
Emacs is written by programmers, for programmers, not for a Marketing organization. Not seeking "pretty" features but focusing on functionally. My instinct when I have this type of question is to search the docs, bc it's all in there
Phovox · 2022-10-24 07:54
I just woke up to read this answer and I already feel as I could go back to bed right now. You did my day dude!!
bondaly · 2022-10-24 12:37
Sometimes I feel like I need something to watch my usage and occasionally remind me of features like this. Let's call it a modern machine learning idea rather than a backwards looking reimplementation of Clippy...
hangingpawns · 2022-10-25 21:03
Does vim have a similar feature?