The R code highlighter
There is an undocumented symbol
RLink`Private`rcell
When you type it and press Shift+Enter, you get a syntax-highlighted R code cell based on my real-time syntax highlighter, which is connected to REvaluate
and highlights the code as you type. Note that the cell where you type RLink`Private`rcell
will be gone, replaced with the new R code cell.
If it is too much typing, you can make an alias like so:
rc := RLink`Private`rcell
and then evaluate rc
instead.
Here is a sample screenshot:
Some details
As noted in my answer about the highlighter, it does perform bracket and parentheses matching / highlighting as well. To make it more responsive, I disables re-parsing on all keys except left/right arrows and space bar, so you will have to press one of those to re-render. Normally they are pressed most frequently when working with code, so this should not be very noticable. Also, the cursor may disappear at times, but again, pressing these keys should make it re-appear. The same remark goes to the visibility of block selection.
Note that, as present, rcell
does not understand the multi-line code string without curly braces. One way to fix this is to execute this code:
ClearAll[RLink`Private`replR]
RLink`Private`replR[code_String] :=
REvaluate["{" <> code <> "}"]
Limitations
For Windows, the highlighter works fine. For other platforms, the highlighter was giving me crashes on some Linux flavors and on Mac. But, I got reports for other Linux flavors that it worked fine there. So, ymmv, but you can give it a try.
Apart from problems on specific platforms, the highlighter may have a few glitches. If you find some, I would appreciate if you report them to me.
CellPrint[TextCell["x + b", "Input", CellEvaluationFunction -> (REvaluate[#1] &)]]
. I belive you shoud be able to define this on a stylesheet level however, but it's not working for me right now. $\endgroup$InputForm
-- at least thats what I conclude when I usePrint
as the function. $\endgroup$