恢复Vim备份 [英] Restore Vim Backups

查看:192
本文介绍了恢复Vim备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vim的文件备份系统只是保存了我的谚语@ $$,但我有一个疑问.

Vim's file backup system just saved my proverbial @$$ but I have a question.

我有vim将备份保存到~/.vim/backups

I have vim saving backups to ~/.vim/backups

要还原它们,我转到目录,然后(按日期排序)将所需的文件复制回了项目文件夹中的必要目录.很容易,只有5个文件.但是,令我惊讶的是,没有明显的方法可以找到每个文件来自哪个目录.我尝试使用vim -r path/to/file,但这似乎使用交换而不是备份文件.由于就我而言,vim不会崩溃(我只是错误地重写了文件),因此这些文件没有交换.

To restore them I went to the directory and (sorted by date) copied the files I needed back to the necessary directories in my project folder. Easy enough, there were only 5 files. However, I'm surprised there's no obvious way to find which directory each file came from. I tried using vim -r path/to/file but that seems to use the swap and not the backup file. Since in my case vim didn't crash (I just mistakenly overwrote the files) there is no swap for these files.

所以主要问题是:还原vim 备份文件的最佳方法是什么?

So the main question is: What is the best way to restore vim backup files?

侧面问题:当我有两个来自不同路径(例如/path/one/file.html/path/two/file.html)的同名文件时,在.vim/backup/目录中会发生什么?

Side question: What happens in the .vim/backup/ directory when I have two same-name files from different paths (e.g. /path/one/file.html and /path/two/file.html)?

推荐答案

据我所知,Vim根本不保存有关文件原始位置的任何信息.

From what I can tell, Vim doesn't save any information at all regarding the file's original location.

保存两个同名文件的备份可能会覆盖现有备份,也可能使用其他名称,具体取决于您.vimrc中的设置.选项备份"将覆盖现有备份文件,但写备份"将重命名新备份,以避免覆盖.

Saving a backup of two same-name files could either overwrite the existing backup or use a different name, depending on what's set in your .vimrc. The option 'backup' will overwrite an existing backup file, but 'writebackup' will re-name a new backup in order to avoid an overwrite.

有关更多信息,请查看Vim的文档-:help backup

Check out Vim's documentation for more info - :help backup

这篇关于恢复Vim备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆