Going Alt-RStats with VSCode

I never want to see another CSV that isn’t rainbow!

Miles McBain https://milesmcbain.xyz

Mid 2017 I got hooked on VSCode. The extension ecosystem is nothing short of a candy shop for editor nerds. I’ve gone from using VSCode for WebVR development - Can you say Chrome debugger?! - to recently wondering if I could build an #rstats data science stack from all these juicy extensions.

It turns out I was wondering at the perfect time. Yuki Ueda is improving the VSCode R extension weekly, and Randy Lai has just taken the whole thing to the next level with an implementation of an R language server - More about that in a minute. Both of these are under heavy active development.

Here I’ll walk you through the pieces of my current setup. Most of these are VSCode extensions, some are other bits of software.

R Extension for VSCode

There’s a good set of features here already. The main niceties I enjoy are highlighters for Roxygen and .Rmd. You also have help with managing your R console. Linting is included, if that’s your cup of tea.

R LSP Client

This is a key piece of the setup, but doesn’t do a lot on it’s own. It’s the VSCode client for the R language server, see next item.

R Language Server

This is where the fun starts. It’s actually an R package! A server written in R that implements the language server protocol (LSP) for R. The LSP is designed to be editor agnostic, so this can work with VSCode alternatives like Atom, Sublime etc.

At time of writing this thing is still in early dev, but it already has some amazing tricks. Some of this stuff is beating out RStudio in UX.

How about hover help?

Scrollable help file on hover

Figure 1: Scrollable help file on hover

Completions and parameter hints?

Autocompletion and function parameter hints

Figure 2: Autocompletion and function parameter hints

Style hints?

lintr style hints

Figure 3: lintr style hints

rtichoke (Formerly Rice)

rtichoke is an alternative R console cut from the same cloth as iPython. In fact it is written in Python, but if you can get past that you’ll find it has some really sweet features. Syntax highlighting with a variety of colour options, multi-line editing, vim/emacs keyboard shortcuts, and an oh so addictive enter-bash mode as seen here.

My favourite thing is the fast and robust completion mechanism. It just feels tighter than RStudio. It doesn’t glitch out. Try it and see what I mean. This goes some way towards compensating for the VSCode editor’s completions being unaware of your R session - something I thought I could not live without until I found rtichoke. Exploring the contents of a model object

Be sure to check out the options listed in the README. I’ve found the following useful to add to my .Rprofile:

    rtichoke.auto_indentation = FALSE, 
    # Makes alignment looks natural when sent to rtichoke by VSCode
    rtichoke.complete_while_typing = FALSE
    # Stops a brief stutter compiling a large parameter completion list for S3 methods like `plot()`

Rainbow Brackets

I remember first seeing this feature back in MS Excel in ’97, when I thought I was ever so clever hacking my calculus assignment. I now suck at calc, so the joke’s on me. But the joy of this not entirely nostalgia driven. I feel like I am genuinely less anxious reading heavily nested code in rainbow flavour.

Lookin' sharp!

Figure 4: Lookin’ sharp!

Rainbow CSV

At the risk of overdoing it… I never want to see another CSV that isn’t rainbow! Note the column identifier on hover!

Material Icon Theme

R logos, Travis icons, colour codes etc for your file tree. They look smart and improve scanability.

Vim Extension

Much more than your average Vim emulator. It integrates with Neovim and even emulates a few popular plugins. I find it close to the real deal without the typical Vim config overhead. Makes RStudio’s Vim emulation look lame by comparison.

Making up the Difference

I have a repo of misc functions, some of which fill in things I miss from RStudio. For example: rend() is my answer to the ‘Knit’ button. I may spin these out into a package of their own in the future.


I am optimistic about VSCode’s future #rstats prospects given how quickly the language server has come along. There’s also some keenness building to try rolling my own VSCode extension or contributing those above. One thing I miss from RStudio are tidyverse-aware completions, e.g. completing the column names of a piped dataset in dplyr functions. Seems like a good opportunity to make a contribution.

Thus completes my post on my VSCode setup. If you’re loving VSCode as well, feel free to @ me on Twitter with your favourite extensions!


If you see mistakes or want to suggest changes, please create an issue on the source repository.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://www.github.com/milesmcbain/website_distill, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

McBain (2018, Feb. 22). Before I Sleep: Going Alt-RStats with VSCode. Retrieved from https://milesmcbain.com/posts/alt-r-with-vscode/

BibTeX citation

  author = {McBain, Miles},
  title = {Before I Sleep: Going Alt-RStats with VSCode},
  url = {https://milesmcbain.com/posts/alt-r-with-vscode/},
  year = {2018}