[ESS] Syntax highlighting in R - again!

S. McKay Curtis smcurtis at stat.washington.edu
Tue May 19 03:21:51 CEST 2009

Hi Peter,

It sounds like the default syntax highlighting is working for you.
ESS just doesn't highlight very much.  So if you've moved from an
editor like Tinn-R, you will probably be disappointed.  A while back,
I gave a hack that I have used to get more highlighting (for functions
in R's "base" package).  You can find my hack here:


As other commenters noted, you might want to do the same thing with
other standard R packages (like "stats", "utils", etc.) to get
highlighting for all the the typical R functions.

Ultimately, I'd like to do what was recommended in that thread---write
some code to automate the whole process (i.e. automatically get the
function names from R packages and read them into the correct
variables in ESS), but I haven't had the time to learn the Lisp I
would need to do that.  Some day...

Hope that helps,

On Mon, May 18, 2009 at 5:50 PM, Peter Geelan-Small
<p.geelan-small at usyd.edu.au> wrote:
> G'day, users.
> I'm afraid I'm asking a question that isn't new to the help list, but
> syntax highlighting in
> R is not working for me.
> I've read the postings on this topic but they don't give me any leads.
> In particular, I've read this posting from 28.6.04:
> "It sounds like you might not be getting the default syntax
> highlighting.  If I have the following in a file called "foo.R":
> test <- function () {
>  if (1 >0 ) {
>    TRUE
>  }
> }
> then the words `test' `function' `if' and `TRUE' are in different
> colours."
> I put the above into a .R file and did get "function" and "if" in one
> colour, "TRUE" and "<-" in another and "test" in a third. However, when
> I type the following under the above code in that buffer, the only thing
> highlighted is "<-":
> dd <- rnorm(10, 50, 10)
> When I open one of my own .R files in emacs, only "<-", comments,
> character strings and some keywords (for, in, if, else) are highlighted.
> No functions or named objects are.
> I'd be grateful for any suggestions.
> I'm running emacs with ESS under Windows XP. I installed
> emacs-22.3-bin-i386.zip and then ess-5.3.11.zip, following instructions
> in README.w32 that comes with emacs and the pdf guide "ESS v5.3.11"
> Thanks,
> Peter
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

More information about the ESS-help mailing list