3.3 Radian
Q: There is no syntax highlighting in the R terminal. How to fix it?
A: Install Radian, an improved R console REPL interface that corrects many limitations of the official R terminal and supports many features such as syntax highlighting and auto-completion.

Q: How to install Radian?
A: In the terminal, run
$pipx install radian
installed package radian 0.6.15, installed using Python 3.13.5
These apps are now globally available
- radian
⚠️ Note: '/Users/menghan/.local/bin' is not on your PATH environment variable. These apps will not be globally
accessible until your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in
your shell's config file (e.g. ~/.bashrc).
done! ✨ 🌟 ✨
$pipx ensurepath
/Users/menghan/.local/bin has been been added to PATH, but you need to open a new terminal or re-login for this PATH
change to take effect. Alternatively, you can source your shell's config file with e.g. 'source ~/.bashrc'.
You will need to open a new terminal or re-login for the PATH changes to take effect. Alternatively, you can source your
shell's config file with e.g. 'source ~/.bashrc'.N.B. If you have zsh as your shell, you need to run source ~/.zshrc instead of source ~/.bashrc.
To find where radian is installed, you can run:
This is the path to the radian executable.
After adding Radian to your PATH, you can invoke it in the terminal by simply typing radian.
$radian
R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Platform: aarch64-apple-darwin20 (64-bit)
r$>Then, in VS Code, you will need to set Radian as the default R terminal. You can also configure other settings for R.
{
"r.rterm.mac": "/Users/menghan/.local/bin/radian",
"r.bracketedPaste": true,
"r.sessionWatcher": true,
}r.rterm.mac: Path to the Radian executable.r.bracketedPaste: Enables bracketed paste mode, which allows pasting code without executing it immediately. This is useful if you want to paste multiple lines of code into the console at once.r.sessionWatcher: Enables session watcher to monitor the R session. Specifically,- Show value of session symbols on hover
- Show plot output on update and plot history
- Show htmlwidgets, documentation and shiny apps in WebView
r.alwaysUseActiveTerminal: always send code to active terminal rather thanvscode-R; helps me to start an R session which is terminated when VSCode exits.r.plot.useHttpgd: Use the httpgd package for viewing plots in a VS Code window or in the browser.
See Extension Settings for a full list of settings of vscode-R that can be set in VSCode’s settings.json file.
3.3.1 Configuration
radian can be customized by specifying the below options in various locations:
$HOME/.config/radian/profile.radian_profilein the working directory
Example of a radian profile
# either `"emacs"` (default) or `"vi"`.
options(radian.editing_mode = "vi")
# enable various emacs bindings in vi insert mode
options(radian.emacs_bindings_in_vi_insert_mode = TRUE)
# show vi mode state when radian.editing_mode is `vi`
options(radian.show_vi_mode_prompt = TRUE)
options(radian.vi_mode_prompt = "\033[0;34m[{}]\033[0m ")
# custom key bindings
options(
radian.escape_key_map = list(
list(key = "-", value = " <- "),
),
radian.ctrl_key_map = list(
list(key = "p", value = " %>% ")
)
)Insert pipe operator
%>%by pressingCtrl+PInsert assignment operator
<-by pressingEsc+-But this does not work when Vim is enabled as it interferes with Vim’s normal mode.
VI support by radian:
options(radian.editing_mode = "vi"): set the default editing mode to vi.options(radian.show_vi_mode_prompt = TRUE): This option will show the current vi mode in the prompt when usingradianin vi mode. The prompt will be colored blue and will display the current mode.[ins]: insert mode[nav]: normal mode
Q: How to restart Radian?
A: Run rstudioapi::restartSession() in the R terminal.