Is there any ready-made solution to that, especially the coloring of the diff lines?
(In other commits there may be even an additional highlighting of the actual changed part of a line with a different background color.

Of course I could 'roll my own' but don't want to reinvent the wheel.

(Searching for LaTeX and diff only seems to mathematical symbols or how to diff LaTeX documents ...)

Thanks for this. I like the idea of taking the plus and minus as 'comment indicators'.
–
uli_1973Apr 4 '13 at 22:15

1

Some apps create patch files that don't have a space after the +/- signs, if you copy & paste the above solution but it doesn't work, try removing the "\ " (slash-space) from the end of the second and third lines that start with "morecomment="
–
danielFeb 7 '14 at 2:18

@MarcoDaniel shouldn't that +1 have been in green:-)
–
David CarlisleMar 30 '13 at 18:11

Changed my accepted answer because the listings approach doesn't affect all environments but can be applied only when applicable.
–
uli_1973Apr 4 '13 at 11:57

@uli_1973 I'll survive the loss of 15 :-) You could of course just locally define \verbatim@processline for the environments that need it, but there is no harm (and some sense) in using an accepted package interface if it supports this.
–
David CarlisleApr 4 '13 at 12:09

Is it possible to adapt the solution to minted package? (I really like minted style, but I got no clue how to highlight part of the code like the diff sections)
–
OxdeadbeefJan 21 at 1:52

The vim module for ConTeXt uses the VIM editor to do the syntax highlighting of files. As such it supports all syntax highlighting for all filetypes supported by VIM (which is a lot). For example, to highlight diff files, you may use:

\usemodule[vim]
\definevimtyping[DIFFtyping][syntax=diff]
\starttext
\startDIFFtyping
@@ -85,8 +85,8 @@
\newcommand{\doctitleifsub}[2]{%
\thispagestyle{empty}
\begin{center}
- \sffamily This document is part of the documentation of \openlilylib%
- \footnote{\url{https://github.com/openlilylib/openLilyLib}},\\
+ \sffamily This document is part of \textbf{\openlilylib}%
+ \footnote{\url{http://www.openlilylib.org}},\\
a collection of resources for the LilyPond notation software%
\footnote{\url{http://www.lilypond.org}}\\
and the \LaTeX{} typesetting system.
\stopDIFFtyping
\stoptext