[Tex/LaTex] Package listings and new language definition

listings

I tried to define a few PowerShell cmdlets for the lstlisting environment, but it seems that the - breaks the definition. So when I try:

\lstdefinelanguage{powershell}{
    keywords = {Get-AzureSubscription,Get-Host,anything}
}

only the keyword anything is detected. Do I have to escape the -, and how?

Thanks for any help.

Best Answer

As Marijn said in his comment you should add alsodigit = {-} in your definition:

\documentclass{report}
\usepackage{listings}

\lstdefinelanguage{powershell}{
    alsodigit = {-},
    keywords = {Get-AzureSubscription,Get-Host,anything}
}

\begin{document}
\begin{lstlisting}[language=powershell]
text anything Get-AzureSubscription
\end{lstlisting}
\end{document}