Recover a vim file from the .un~ file without the undo command

前端 未结 4 606
温柔的废话
温柔的废话 2021-02-12 20:10

How can I restore a vim file from the undo file without hitting undo?

I had a vim file that I saved while adding text. Then I ran a python comm

4条回答
  •  被撕碎了的回忆
    2021-02-12 20:38

    You can't. The undo information is linked to Vim's last knowledge of the file's contents; when they don't correspond any more, Vim cannot re-apply the changes. This is documented at :help undo-persistence:

    Vim will detect if an undo file is no longer synchronized with the file it was written for (with a hash of the file contents) and ignore it when the file was changed after the undo file was written, to prevent corruption.

    Best you can do is try to manually salvage recognizable bits in the undo file, e.g. with a hex editor, or Vim's binary mode.

提交回复
热议问题