比较 Vim 中的两个选项卡
场景:我打开了 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 diff
ing two open but unsaved buffers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
所有选项卡的内容都在缓冲区内。
查看缓冲区:
找到应该与当前选项卡内容不同的内容的正确编号。
打开当前选项卡内的缓冲区(fe 缓冲区号 4)
或执行垂直视图:
然后您可以简单地比较内容
如果您完成了比较分析,您可以输入:
The content of all tabs are inside the buffers.
Look at the 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)
Or do for vertical view:
Then you can simple diff the content with
If you finished diff analysis you can input:
当您以垂直拆分方式打开两个文件时,运行
:windo diffthis
When you have two files opened in vertical splitt, run
:windo diffthis
我建议尝试 :diffthis 或 :diffsplit
I would suggest trying :diffthis or :diffsplit
我建议在同一选项卡中打开第二个文件,而不是打开新文件。
这是我通常做的事情:
:vnew
命令垂直分割当前视图,以便您可以在那里打开第二个文件。:diffthis
(或简称::difft
) 命令然后应用于每个视图。I suggest opening the second file in the same tab instead of a new one.
Here's what I usually do:
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.