比较 Vim 中的两个选项卡

发布于 2024-07-26 13:16:19 字数 200 浏览 3 评论 0原文

场景:我打开了 Vim 并粘贴了一些文本。 我使用 :tabe 打开第二个选项卡,并在其中粘贴一些其他文本。

目标:我想要第三个选项卡,其输出相当于将两个文本写入文件并使用 vimdiff 打开它们。

我能找到的最接近的是“将当前缓冲区与文件进行比较”,但不是比较两个打开但未保存的缓冲区。

Scenario: I have opened Vim and pasted some text. I open a second tab with :tabe and paste some other text in there.

Goal: I would like a third tab with a output equivalent to writing both texts to files and opening them with vimdiff.

The closest I can find is "diff the current buffer against a file", but not diffing two open but unsaved buffers.

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

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

发布评论

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

评论(4

忱杏 2024-08-02 13:17:05

所有选项卡的内容都在缓冲区内。
查看缓冲区:

:buffers

找到应该与当前选项卡内容不同的内容的正确编号。

打开当前选项卡内的缓冲区(fe 缓冲区号 4)

:sb 4

或执行垂直视图:

:vertical sb 4

然后您可以简单地比较内容

:windo diffthis

如果您完成了比较分析,您可以输入:

:windo diffoff

The content of all tabs are inside the buffers.
Look at the buffers:

:buffers

Find the right number for the content which should be diffed with your current tab content.

Open the buffer inside your current tab (f.e. buffer number 4)

:sb 4

Or do for vertical view:

:vertical sb 4

Then you can simple diff the content with

:windo diffthis

If you finished diff analysis you can input:

:windo diffoff
酷炫老祖宗 2024-08-02 13:17:00

当您以垂直拆分方式打开两个文件时,运行


:windo diffthis

When you have two files opened in vertical splitt, run


:windo diffthis

栖迟 2024-08-02 13:16:55

我建议尝试 :diffthis:diffsplit

I would suggest trying :diffthis or :diffsplit

稀香 2024-08-02 13:16:49

我建议在同一选项卡中打开第二个文件,而不是打开新文件。

这是我通常做的事情:

:edit file1
:diffthis
:vnew
:edit file2
:diffthis

:vnew命令垂直分割当前视图,以便您可以在那里打开第二个文件。 :diffthis (或简称::difft) 命令然后应用于每个视图。

I suggest opening the second file in the same tab instead of a new one.

Here's what I usually do:

:edit file1
:diffthis
:vnew
:edit file2
:diffthis

The :vnew command splits the current view vertically so you can open the second file there. The :diffthis (or short: :difft) command is then applied to each view.

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