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

前端 未结 4 628
温柔的废话
温柔的废话 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:54

    As the other answers have noted, you can't recover the whole file from vim's undo files, simply because vim seems to only keep diffs in the undo files, not the whole contents. (That makes a lot of sense, as it's space efficient.)

    One thing you can try though, is to extract what's possible from your undo file:

    $ strings 
    

    The output will not be pretty, but you could end up finding something that's valuable to you.

提交回复
热议问题