I really like the listings package but often it drives me crazy :). I want to have listings of the programming language R (statistic stuff). Here's a minimal example:
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{
language=R,
basicstyle=\ttfamily,
keywordstyle=\color{red}\bfseries,
}
\begin{document}
\begin{lstlisting}
my_Variable <- qnorm(0.05/2, mean=0, sd=1)
>> 1.959964
\end{lstlisting}
\end{document}
Here's the result:

Here's the problem:
- Even in the comment the dash is highlighted.
- The underscore in the Variable name is highlighted too.
I have tried to use the deletekeywords={_,/} option - but without success. I also tried alsoletter. Maybe someone could point out my mistake.
EDIT 1: If it's possible I do not want to change the actual code (listing) as in the first answer. Because then the code won't be suitable for my programming language (in my case R) any more.
EDIT 2: Any help is appreciated. How can I make it easier to help?



knitrorsweave? With either of these the source document contains both the runnable R code and the LaTeX text. – Ethan Bolker Oct 20 '12 at 13:34