Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim - restore lost file from vim undo file

Tags:

vim

I accidentally deleted my .vimrc which took me weeks to config. I still keep the undofile and I think that's the only way I can restore it. Unfortunately, vim now does not allow me to undo (I guess because my current vimrc version cannot be "patched" with the last undo step).

Also, vim undo file is encoded so I cant see its content in human readable form. There was a step where I just deleted all my vimrc with ggvGc and so if there is a way to decode that vimundo file, I think I can restore it.

Is there anyway I can get my vimrc back? Thank you.

like image 910
boh Avatar asked Jul 05 '15 16:07

boh


2 Answers

For people coming here years later, it's not possible in recent versions of Vim.

You could try running this to extract what you can from the undo file:

$ strings <undo-file>

See Recover a vim file from the .un~ file without the undo command for more information.

like image 190
aude Avatar answered Oct 03 '22 13:10

aude


So, as FDinoff suggested, the patch here really works for me.

like image 41
boh Avatar answered Oct 03 '22 15:10

boh