VIM - 显示上次保存版本和当前未保存版本的差异

发布于 2024-07-17 04:36:10 字数 585 浏览 4 评论 0原文

可能的重复:
我可以在保存文件之前查看更改吗Vim?

重复:我可以在保存我的文件之前查看更改吗? Vim 中的文件?

有没有办法在 VIM 中查看同一文件的保存版本和编辑版本的差异?

这是这样的场景:我打开了一个文件,编辑了一些内容,然后由于一些工作而离开了计算机。 一段时间后,我回来了,我忘记了我正在编辑的内容,我想看看同一文件的上次保存版本和当前未保存版本之间的差异。 有办法做到吗?

当然,我可以继续撤消直到最后一次更改,然后开始重做以返回到未保存的版本。 但我想看到的是差异。

Possible Duplicate:
Can I see changes before I save my file in Vim?

Duplicate: Can I see changes before save my file in Vim?

Is there a way to see the diff of the saved version and the edited version of the same file in VIM?

This is the scenario: I've opened a file, editing something and I went away from the computer due to some work. After sometime I returned back and I forgot what I was editing and I would like to see the difference between the last saved and the current unsaved version of the same file. Is there a way to do it?

Of course, I can keep undoing till the last change and start redoing to go back to my unsaved version. But what I would like to see is a diff.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

当梦初醒 2024-07-24 04:36:11
:w !diff % -
:w !diff % -
一念一轮回 2024-07-24 04:36:11

显然 :DiffOrig 做的事情与自定义函数相同,在 Golubyev 先生的帖子中做了几个深入的链接。 不过,默认情况下它可能只存在于较新版本的 Vim 中。

Apparently :DiffOrig does the same thing as the custom function did a couple links deep into Mr. Golubyev's post. It may only be in newer versions of Vim by default, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文