7

Is there a way to rename/copy/move a file and maintain the vim persistent undo information?

If I do

:w new-file-name

and then

:e new-file-name

I can't hit u to undo. Already at oldest change :-(

4

Using :saveas keeps the undo history intact.

:saveas is equivalent to the combination of :w newname followed by :e #. I usually find it more handy than the :w + :e, especially since with :saveas it's not really possible to forget about doing the second command and end up editing the first file. (Which you can guess is something I've done more than once!)

| improve this answer | |
1

Tim Pope created eunuch plugin with such feature. It has :Move and :Rename commands. Do not know if it works under Windows since description is about UNIX shell commands, can't test it right now. Also as filbranden said you can copy with :saveas.

| improve this answer | |

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.