6

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.

3 Answers 3

4

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
1
  • That's not what I was hoping for, but I guess it will have to do. Commented Nov 18, 2008 at 19:39
3

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

$ diff -y --suppress-common-lines oldfile newfile | \
  a2ps -l 130 --columns 1
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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.