使用 gvim 打印差异?
有没有一种方法可以打印出差异,就像您使用“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为没有办法获得两个不同文件的并排打印输出。 但是,您可以对要比较的两个文件中的每一个使用 Vim 的“转换为 HTML”工具,并将它们分别打印出来。 然后您可以将它们并排堆叠以获得相同的效果。
转换为 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.
我很幸运地使用 diff 和 a2ps 的组合:
I have had luck using a combination of diff and a2ps:
首先,
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 setg: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.