Tuesday, July 11, 2023

Re: vim: revert a specific change in the undo history

On Tue, 11 Jul 2023, 20:26 Christian Brabandt, <cblists@256bit.org> wrote:

On Di, 11 Jul 2023, ping song wrote:

> say I've done 3 changes A, B, C.
> but I realized B is a big mistake. A and C is good.
> can I just delete change B, but keep A and C?

I believe this is not possible. What you can do is, copy the whole
buffer at state C, move back to state A and clear the buffer and paste
the content from State C (effectively creating a new change A->D)

An alternative would be to use the history commands to get at each version and either use diff/patch tools or a 3-way merge tool like BeyondCompare to sort it out.

e.g. (untested):

* Open file at State C
* :w statec.txt
* Revert to State B
* :w stateb.txt
* Revert to State A
* :w statea.txt
* diff -u stateb.txt statec.txt > c_changes.diff
* patch -p0 statea.txt < c_changes.diff

(check all of those commands before running as they were off the top of my head!)

--
--
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/CAOaJ26Q_D3ny8cc6Bt8ACUB4LMWbR-kN6emaV9uUbh32nZFMxg%40mail.gmail.com.

No comments:

Post a Comment