1
votes

I use Eclipse, StatET and the Sweave plugin to write my R and Latex code. The cool thing is that R and Latex code can be put together into one file, however you end up with a syntax highlighting problem.

I have loads of R code and I very much like the Eclipse R syntax highlighting. But now combining R and Latex means that I have to work with .Rnw files where there is no particular syntax highlighting for R.

When I go to Eclipse -> Preferences -> Content Types I can add *.Rnw to "R script file" which makes Eclipse to open the .Rnw files with the standard R Editor. However, this means that I do not have syntax highlighting for Sweave any longer. In addition, the Sweave code is shown as an error in the R editor.

My question is whether it is possible to combine different syntax highlighting styles in an easy way?

1
It works fine for me, and I don't recall having done anything special. All of my R code chunks inside .rnw files are highlighted as expected.Andrie
I reinstalled my StatET and now syntax highlighting in the .Rnw file works for me now too. Don't know what was wrong. I played around a lot with all of the settings maybe I set some wrong parameters. But what still remains is that in the .Rnw files you do not have auto-completion for the R commands. For instance, if you type libr and then press CTRL+Space it gives you the possibility to add library() which is not the case in the .Rnw file. What a shame :(user969113
I "solved" this by writing code in a separate file and once it's production grade, I copy paste it into a Sweave chunk.Roman Luštrik

1 Answers

1
votes

I don't think any Eclipse plugins/editors really support mixing up several syntaxes inside one editor. At any rate it is not currently supported in Eclipse Platform.

However you can try Eclipse Colorer plugin. It allows to switch coloring style for the current editor. It may mot support both R and Latex syntax, but you can create your own highlighting by adding your own HRC file.