Monthly Archives: August 2011

Syntax highlighting of roxygen documentation in TextMate

With roxygen now on github, the release of roxygen2 and Hadley’s might now behind the project I expect roxygen to gain even more momentum.

R development in TextMate is great with the R bundle. Unfortunately the R bundle does not support highlighting of roxygen documentation by default. That was always a sticking point for me switching to roxygen because TextMate has really nice highlighting for Rd files.

So I hacked on the syntax file to get at least some preliminary highlighting of stuff after roxygen comments (#'). The file is in a gist over at github. It doesn’t yet work quite as well as I would like but it is better than nothing. In particular, highlighting of R code in examples does not work. Contributions/additions are welcome.

You must have must have the R bundle installed. The easiest way to install is to open the bundle editor (“Bundles” > “Bundle Editor” > “Show Bundle Editor”) and copy this file over the R syntax file from the R bundle. Then “Reload Bundles” or restart TextMate.

You may need to install the R bundle first if you have not already:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd /Library/Application\ Support/TextMate/Bundles
svn co

Then either reload the bundles or restart TextMate to get the bundle activated.