Alternative R consoles

The built in R console in RStudio is pretty decent, but a little underwhelming. For example, it would be great to have the same syntax highlighting provided from the editor. I saw on Reddit the other day and have been playing around with it. While I have run into a couple issues, I have been able to debug them myself without too much time invested and in general have really enjoyed using it. It would be cool to able to swap the default R console in RStudio for other options like rice or Jupyter IRkernel or anything else that can execute R code. Alternatively, be able to choose to send R code to the new integrated terminal instead of the R console.

** side note: I think I should be able to just send lines in any code file to the integrated terminal regardless if it would actually execute or not

Did you try the new preview version 1.1 of RSTUDIO?
It has syntax highlighting in console. Here is an example:

From a tweet

If RStudio doesn't float your boat, I'm a big fan of Visual Studio Code. It has an integrated terminal, and the integrated Git support is pretty nice too :slight_smile:


That's still in the source/editor pane, not the console.

What the preview does allow is sending code to a terminal (ctrl-alt-Enter), which means that you could theoretically use rice from there. In a quick test, though, it produces reasonably good results, though my current color scheme isn't great with the colors that rice uses.


@rensa The VSCode R extension is getting better by the week!

@milesmcbain I haven't actually tried it! I'll check it out :slight_smile:

Yep, I have my own fork of the rocker/rstudio-daily so I can spin up and try the RStudio daily build through docker. The console doesn't provide syntax highlighting as of yesterday when I tried it. I believe that was 1.1.370

Ahhh... I missed the alt key. I thought it was the same key combination as sending R to the R console (cntl+enter). Yeah, this is good enough for my needs! Thanks for pointing that out!

I actually use both a lot, as well as sublime text. RStudio for all my R code, sublime is my preference for python, vscode I use for Go. I had problems with gosublime package and saw my co-workers using vscode so gave it a shot. So far it's been pretty nice, though slows down quite a bit when using tools that watch your code and rebuild on save.

It seems I have the same syntax highlighting in source and console. hence my initial answer.
highlight disappear for already run lines (purple just above ggplot commands. )

That's really strange -- how are you sending the code to the console? None of the techniques that I normally use would process that code as a block; it would run it line-by-line since each line is a complete statement. Also, even in that example, it's not highlighting your earlier code, just the code from the source.

There is indeed a command which does this! The default keybinding is Ctrl Alt Enter.

There's a new option in 1.1 which allows you to run "paragraphs" of code (that is, a region delimited by blank lines). You can flip it on in Options -> Code -> Execution, and there's also a new Execute Paragraph command which you can bind to a key combo of your choice.

1 Like

I had forgotten about that option, but even trying that, I still get a new > prompt shown after each complete code block, and it's definitely not highlighted as shown in @cderv's screenshot. Is that a different feature that I also missed? I like surprise features!

Nope, that screenshot is definitely of the source pane, not the console (notice it has line numbers which definitely don't exist in the console!).

I meant this screenshot from later in the thread (at the bottom of the image):

I'm just very curious how that worked.

I actually haven't been able to get this to work yet. I downloaded the new preview version today and my console highlighting is still the same.

I might be stating the obvious here, but there is a setting that allows the console to mirror the syntax highlighting of the editor for unevaluated code. As seen in the screenshot being discussed, once code is evaluated the syntax highlighting disappears.
28 PM


Honestly, I have no idea how I didn't know about that... I feel like syntax highlighting should be the default option. Thanks for pointing that out!

Yup, was completely missing that! I figured it was something obvious, but that didn't help me find it. Thanks!

Checking that "Highlight R function calls" box can help differentiate between objects and functions. Since differentiation between nouns and verbs is a core axiom of syntax highlighting, it seems like it should be checked by default, too.