Menu

#557 Support syntax highlighting for R

none
open
nobody
None
5
5 days ago
2026-04-13
goebbe
No

This is a feature request for supporting syntax highlighting for R.
R is a popular language for statistical analysis: https://www.r-project.org/about.html

R-programs use the .R or .r suffix.
In Jedit 5.5 (LinuxMint), this suffix is used for rebol-language.

However, 13 years ago, in 2013, rebol moved from .r to .reb as a new standard for suffixes:
https://www.rebol.com/article/0540.html

I use the following mode entry for R:

<MODE NAME="rlang"          FILE="rlang.xml"
        FILE_NAME_GLOB="*.{r,R}" />

The old rebol entry in the catalog file should probably be changed to:

<MODE NAME="rebol"      FILE="rebol.xml"
        FILE_NAME_GLOB="*.reb" />

With respect to its syntax, R-lang has strong resemblance to S and Splus.
For my personnel use, I just copied/ pasted the splus.xml syntax file, renamed it to rlang.xml and commented one single line. (For the use of "_" which is allowed in R, but not in Splus)

I use this syntax highlighting successfully with different R-projects and didn't spot any problems.

Best regards.

1 Attachments

Discussion

  • goebbe

    goebbe - 2026-04-14

    The attached update for the syntax-highlighting file
    introduces the following changes:

    • "_" is removed from "wordBreakChars", instead
    • "_" is now INVALID AT_WORD_START
    • "%" is removed from SEQ TYPE= "OPERATOR", instead
    • "%" is now SPAN TYPE="OPERATOR" for %in% or %>% ...
    • DIGITS now also work for
      • Integer digits: 1L, 55L
      • scientific notation: 1e5 , 2.5e-3, -1e10, -6.713e+09, 2.340e+10
      • complex numbers: 1+4i, 9 + 3i
    • FUNCTION names are highlighted if they contain "." e.g.: is.na() as.data.frame()
    • KEYWORDS for TRUE, FALSE
    • KEYWORDS for null-able values: NULL, NA, NaN, Inf
     

    Last edit: goebbe 2026-04-14
  • goebbe

    goebbe - 5 days ago

    I did some final clean-ups and optimizations:

    • delete / optimize redundant regexp
    • clean up highlighting of function names
    • remove "label:" syntax - which does not exist in R
    • add "T" and "F" as short version of "TRUE" and "FALSE" (default aliases in R).

    I also attach a test file to check syntax highlighting of R-scripts.

    From my point of view this could go in.

     

Log in to post a comment.