16

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?

22

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.