I am using listings
to display custom keywords in bold. In my listings, those keywords are sometimes followed by a comma. However, in the example below, any comma following a keyword will prevent the keyword from being recognized.
How can I make listings
recognize CustomKeyword
and if
as keywords, even when they're immdiately followed by a comma ?
\usepackage{lstlistings}
\lstdefinelanguage{csharp}{
alsoletter={@,=,>,},
morekeywords={return, if, is, int, CustomKeyword, else, or, bool},
sensitive=true,
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]"
}
\lstset{
language=csharp,
showstringspaces=false,
columns=spaceflexible,%fullflexible,
mathescape=true,
numbers=none,
numberstyle=\tiny,
basicstyle=\codestyle
}
\begin{lstlisting}[columns=fullflexible]
CustomKeyword // OK in bold.
CustomKeyword, // Not in bold anymore.
if //OK in bold
if, // Not in bold anymore
\end{lstlisting}
alsoletter=@=>,
instead ofalsoletter={@,=,>,},
; the latter defines,
as a "letter", which means thatlistings
treats it as a valid character in identifiers and keywords.