flowchart TB
subgraph sync["Settings Sync"]
profile["VS Code profile 'R'<br/>settings · keybindings<br/>snippets · tasks · extensions"]
end
subgraph machine["Each machine"]
path["PATH"]
radian["radian<br/>(Python 3.12)"]
rig["rig shortcuts<br/>C:\Program Files\R\bin"]
r["R x.y.z<br/>(rig default)"]
lib["package library<br/>per R version"]
rprofile[".Rprofile<br/>(OneDrive)"]
end
profile -- "r.consolePath: radian" --> path
path --> radian
path --> rig
radian -- "R on PATH" --> rig
profile -- "language server, help" --> rig
rig --> r
r --> lib
r --> rprofile
VS Code for R
I write R in VS Code, on more than one Windows machine. These pages describe the set-up in enough detail that I (or you) can rebuild it, and include my configuration files.
My set-up in short
I use VS Code with the vscode-R extension for all my R work, on Windows. R runs in radian, a modern R console with syntax highlighting and multi-line editing, opened in a terminal panel docked on the right. Plots go to the httpgd viewer inside VS Code. The languageserver package gives autocompletion, hover help and go to definition; lintr checks the code as I type, and styler formats it when I ask. I write documents, slides and this website in Quarto, with the Quarto extension for preview and code-chunk execution. rig manages several R versions side by side, and renv with targets keeps each project reproducible (project template). Git work happens in the built-in Source Control view, with GitLens, Git Graph and the GitHub Pull Requests extension. For AI help I use GitHub Copilot and Claude Code. The look is the built-in Visual Studio Dark theme with vscode-icons, and a set of custom keybindings (for example Ctrl+Shift+M for the pipe) makes the common R actions one keystroke. Everything is kept in one VS Code profile called R, synced between my machines.
It pairs with two other things I use daily:
- my project template for reproducible R projects (renv, targets, tests, instructions for coding assistants);
- the R Version Switcher extension, for per-project R versions (R versions).
The idea
One environment on every machine, with no machine-specific paths.
- VS Code’s Settings Sync carries settings, keybindings, snippets, tasks and extensions between machines.
- That only works if the synced files contain no user names and no install paths. So nothing in them says where R is or which version: VS Code starts
radian, radian startsR, and both are found onPATH. - rig decides which R that is, per machine, with
rig default. Changing the R version never touches VS Code. - The few things Sync cannot carry (task scripts,
.Rprofile, PowerShell profiles) follow the same rule..Rprofileand the PowerShell profiles are shared through OneDrive; the task scripts I copy by hand.
How the pieces fit
The pages
| Page | What is in it |
|---|---|
| Install, in order | VS Code, rig and R, Python and radian, Rtools, the R packages, Quarto, ripgrep, with winget commands and the versions I use. |
| Settings | The settings of the R profile and what they do. |
| Keybindings | My keybindings, what they replace, and the layout presets. |
| Extensions | My extensions, grouped, with the minimum set for R and an install script. |
| Snippets and tasks | Quarto snippets, the two VS Code tasks and their scripts. |
| Profiles and Settings Sync | How profiles work, the sync gotcha that drops R settings, the Default and teaching profiles. |
| Outside VS Code | .Rprofile, radian, PowerShell, git, and the PATH rules. |
| R versions | Switching R for the machine or pinning it per project. |
| Troubleshooting | Problems I have run into, with fixes. |
Rebuild from scratch
On a new Windows machine:
- Install everything in the order on Install, in order (steps 1–9).
- VS Code profile. Either sign in to Settings Sync (on my own machines), or create a profile called
Rand fill it in from the published files:- settings: settings.json → Preferences: Open User Settings (JSON);
- keybindings: keybindings.json → Preferences: Open Keyboard Shortcuts (JSON);
- snippets and tasks: Snippets and tasks;
- extensions:
install_extensions.ps1from Extensions.
- Sync gotcha. Make sure
settingsSync.ignoredSettingsis also in the Default profile (why). - Outside VS Code: put
.RprofileinDocuments, the task scripts in%USERPROFILE%\.vscode-scripts\, and runrig system fix-r-alias(details). - Check
PATHagainst the rules: noR_HOME, noR-x.y.z\bin, Python 3.12 first. - Restart VS Code completely, open an R terminal, approve the
sessinstallation it asks for, and runplot(1:10)(test).