Save vimdiff output?

落花浮王杯 提交于 2020-04-07 11:27:51

问题


I google'd this multiple times in the past but I've never found an answer. Is there a way to save vimdiff's output (preferably while maintaining colors, highlights, etc.)? I'd like to send this one output file to other people and tell them "just open this file, here are the differences, side by side and highlighted".

If there are better alternatives to vimdiff for this purpose, I'm open to suggestions - something that would work on both Windows and Linux platforms is ideal.


回答1:


Vim can export to HTML, see:

:help :TOhtml



回答2:


To compare two files and write out the result to a third file "HTML based". Open a terminal and run this command:

vimdiff  file1.txt file2.txt -c TOhtml -c 'w! diff.html' -c 'qa!'



回答3:


You'll get similar output with the next command:

sdiff file1 file2 | colordiff



回答4:


There are at least two options for saving vim colouring: it is :TOhtml distributed with vim itself and more advanced my format.vim plugin. Advantages of my plugin over :TOhtml are described on the plugin page. Command to format vimdiff to html:

:Format diffformat



回答5:


diff -u file1 file2 > outputfile


来源:https://stackoverflow.com/questions/7475244/save-vimdiff-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!