Wednesday, March 4, 2020

Re: vim undo

On 2020-03-04 13:00, Chris Jones wrote:
> Scenario:
>
> - I open a file
> - I make one big global change (C0)... say via substitute+regex
> - I proceed to make more changes (C1, C2, ... Cn).
>
> While *still editing the file* I realize that the initial change
> (C0) was in error.
>
> Can I undo the initial change (C0) and keep all the ensuing changes?
>
> Or...
>
> Go back to the initial state of the buffer, and make vim reapply
> all the C1-Cn changes?
>
> Standard vim only please, no plugins.

I don't think there's a native way to play back all the changes as a
rebase. If I had a dire need to do as much, I'd do a little
do/undo/diff/patch tango, something like

:w current.txt

then undo to C1

:w c1.txt

then undo once more take you back to the pre-C0 change and save that:

:w pre-c0.txt

Then, in the shell

$ diff -u c1.txt current.txt > rest_of_the_changes.txt

and run that patch against the pre-c0.txt

You might be able to use git to checkin various points and then
use its rebasing to help you out.

But in pure vim? Not much.

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200304121950.7fbf49a1%40bigbox.attlocal.net.

No comments:

Post a Comment