使用 gvim 打印差异?

发布于 2024-07-09 04:42:52 字数 113 浏览 5 评论 0原文

有没有一种方法可以打印出差异,就像您使用“gvim -d”打开它们时显示的那样,所有通用代码都折叠起来,只有差异在上下文中显示? 我尝试了打印菜单选项,但它打印了我当前“所在”的整个文件,而不是打印折叠的差异。

Is there a way to print out the diffs like they show when you open them with "gvim -d", with all the common code folded away and only the diffs showing in context? I tried the print menu option, but it printed the entire file that I was currently "in", rather than printing the folded diffs.

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

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

发布评论

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

评论(3

做个ˇ局外人 2024-07-16 04:42:52

我认为没有办法获得两个不同文件的并排打印输出。 但是,您可以对要比较的两个文件中的每一个使用 Vim 的“转换为 HTML”工具,并将它们分别打印出来。 然后您可以将它们并排堆叠以获得相同的效果。

转换为 HTML 是一种“漂亮的打印”——它保存所有视觉颜色/语法/折叠信息。

:he convert-to-HTML

I dont think theres a way to get a side by side printout of the two files being diffed. But, you could use Vim's "Convert to HTML" tool on each of the two files being diffed and print those out separately. You could then stack them side by side to get the same effect.

Convert to HTML is kind of "pretty printing" - it saves all of the visual colour/syntax/fold information.

:he convert-to-HTML
扮仙女 2024-07-16 04:42:52

我很幸运地使用 diff 和 a2ps 的组合:

$ diff -y --suppress-common-lines oldfile newfile | \
  a2ps -l 130 --columns 1

I have had luck using a combination of diff and a2ps:

$ diff -y --suppress-common-lines oldfile newfile | \
  a2ps -l 130 --columns 1
零時差 2024-07-16 04:42:52

首先,TOhtml 插件 @Gowri 正在讨论,能够输出一个 HTML,并显示两个文件(除非您将 g:html_diff_one_file 设置为 1)。 其次,如果你对 TOhtml 的输出不满意,你可以尝试我自己的 formatvim(本例中使用的命令::Format diffformat(可能会被截断为:Format d))。 它在 html 输出方面有更多的功能,但我费心编写它的主要原因是你可以编写自己的输出格式规范,所有与 html 有关的东西都保存在一个地方。

First, TOhtml plugin @Gowri was talking about, is able to output one HTML with both files shown (unless you have set g:html_diff_one_file to 1). Second, if you are not fine with output of TOhtml you can try my own formatvim (command to use in this case: :Format diffformat (may be truncated to :Format d)). It has a bit more features in html output, but the main reason why I bothered with writing it is that you can write your own output format specification, all things connected to html are kept in one place.

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