# Package listings and new language definition

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.

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user36296 Jun 29 '16 at 16:22
• As per the manual on ctan.org/pkg/listings?lang=en you should put alsodigit = {-} in your language definition. – Marijn Jun 29 '16 at 17:37

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}