vim - 如果在 Vim 之外编辑文件,则保留撤消历史记录

标签 vim

在编辑器外编辑文件时,Vim 撤消文件将被清除。

我怎样才能得到它以便我可以将文件恢复到旧版本,即使它是在 Vim 之外编辑的?这可能吗?

最佳答案

您可以使用 vim 备份:

set backup                   " enable backup file
set backupdir=~/.vim/backups " backup directory

然后你可以去获取保存的最后一个备份 vim,以防你想在外部编辑后恢复,但这不像撤消文件。 From vim wiki :

However, note that if a file is modified externally without Vim, Vim will not be able to read the undo history back when you start editing the file again and the undo tree information will be lost. There is no way to get it back.

关于vim - 如果在 Vim 之外编辑文件,则保留撤消历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16975891/

相关文章:

vim 语法高亮提高性能

vim - NERDTree 在新选项卡中打开,作为 gvim 中的最后一个选项卡?

bash - 不要在 vim 的 shell 中自动完成文件名的某些扩展名

vim如何剪切文本并插入新行

string - 关于连接变量和常量字符串的 vim 脚本

git - 为什么有时会出现 Git merge VIM 屏幕

vim - 在vim中突出显示行时隐藏拼写错误

vim - gVim - Ubuntu - 窗口不断调整大小

vim - 如何更改 Vim 用于为缓冲区中的空白行编号的字符?

vim - 使向后运动始终包括在内?