danns87
danns87

Reputation: 1070

Save vimdiff output?

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.

Upvotes: 55

Views: 33235

Answers (5)

z atef
z atef

Reputation: 7709

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

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

Upvotes: 39

user6833918
user6833918

Reputation: 27

diff -u file1 file2 > outputfile

Upvotes: 1

ZyX
ZyX

Reputation: 53674

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

Upvotes: 4

Raimondi
Raimondi

Reputation: 5303

Vim can export to HTML, see:

:help :TOhtml

Upvotes: 39

uzsolt
uzsolt

Reputation: 6037

You'll get similar output with the next command:

sdiff file1 file2 | colordiff

Upvotes: 12

Related Questions