Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore deleted file #116

Open
MyMyrtle opened this issue Nov 6, 2020 · 3 comments
Open

restore deleted file #116

MyMyrtle opened this issue Nov 6, 2020 · 3 comments

Comments

@MyMyrtle
Copy link

MyMyrtle commented Nov 6, 2020

Hi,

I have deleted a file which I would like to restore. I can see the undo file is still there, for example:

ls ~/.vim/tmp/undo/%etc%sysctl.conf

Of course when I try to open /etc/sysctl.conf it is empty and no undo tree is visible in vim. Even trying rundo ls .vim/tmp/undo/%etc%sysctl.conf says "File contents changed, cannot use undo info". Is there any option to recover it with the undo info?

I love undotree!!

Best

@mbbill
Copy link
Owner

mbbill commented Nov 9, 2020

AFAIK VIM's undo file (in this case the one under you .vim/tmp/undo/ folder) doesn't store all the file contents for each undo version, instead it saves the diff, which means you need the original file as the base version in order to go back to any of the history versions. So I'm sorry you lost your file, but it seems like there isn't much you can do for it.
However, if you happen to have a swap file, you might be able to restore it.

@VimWei
Copy link

VimWei commented Apr 3, 2024

However, if you happen to have a swap file, you might be able to restore it.

I creat a wiki page with vimwiki, and there is a : in the name such as 20240322foo10:00bar.md.
Vimwiki can create, edit and save this page. And this page can be reopened with the same name after closing Vim.
However, I found that the page file is actually saved as short name 20240322foo10 on the disk and the file size is 0.

image

And undotree work fine with the full name 20240322foo10%00bar.md.

image

Because I discovered the problem later, I deleted those zero-size files. Fortunately, I have backups of these files. However, when I put the backup files back and Vimwiki opens them with the original full names, the content is blank, and I can't use undotree either.

Is there any way to restore the files in this situation?

@mbbill
Copy link
Owner

mbbill commented Apr 3, 2024

tbh I'm not exactly sure what's happening here. I guess you might have hit some weird rare edge case bugs or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants