How can I apply a certain style to C (or, well, any other programming language) operators? So that when I write
\begin{lstlistings}[language=C++]
int i = 0;
if(i > 1) {
// do something
}
\end{lstlisting}
I'll get =
and >
(and other operators, and preferably also (
and )
, {
and }
) highlighted in red, for instance? I managed to treat those characters like other keywords (bold and blue in my case), but this isn't the behavior I want, and it destroys comment definitions.
Best Answer
Here is a workaround that doesn't break one-line comments and only applies the desired style to operators outside comments and strings.
Caveats:
listings
classifies as "other".