It happens quite often that I want to undo changes locally or line-wise. For example, when I change multiple lines in a source code and I want to revert only one of them, then I have to step through the entire undo tree to find the state I want to return to. It would be better if I could only revert the marked region or the line where the point is. Is there something like this already in existence?
Asked
Active
Viewed 527 times
1 Answers
23
This is standard Emacs functionality (since 1998 / 20.3).
Assuming you have transient mark mode enabled, just mark the region, and use undo as normal, and Emacs will perform undo operations relevant to the (active) region only.
With transient mark mode off, or if the marked region is not active, use a C-u prefix argument to the undo command.
See: C-hf undo
or "selective undo" in the manual: C-hig (emacs) Undo

phils
- 48,657
- 3
- 76
- 115