Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top