3.12 FAQ
Q: I cannot see my R Objects in the global environment.
A: when you click on “R: (not attached)” on the bottom bar or type .vsc.attach() into the terminal, your objects should start showing up in your global environment.
Q: How to hide variables in OUTLINE view?
A: OUTLINE view by default shows all variables in the current R script, making it difficult to locate your true sections. To hide variables, go to command palette, type “Outline: Show”, there is a list of objects that you can choose to show or hide (you can choose to set this for workspace or the user). Here is my current setting:
{
"outline.showArrays": false,
"outline.showBooleans": false,
"outline.showClasses": true,
"outline.showConstants": false,
"outline.showFields": false // this hides most variables you actually don't want to see
}Note that some answers mention that you should use
"outline.showVariables": false, but this does NOT work for me. Instead, I use"outline.showFields": falseto hide most variables.
To set outline appearance for a specific language, you can use the following settings:
{
"[r]": {
"outline.showArrays": false,
"outline.showBooleans": false,
"outline.showClasses": true,
"outline.showConstants": false,
"outline.showFields": false
},
"[rmd]": {
"outline.showKeys": false,
}
}- Set
outline.showKeysto false will prevent code chunks from being shown in the OUTLINE view of Rmd files.
Multiple language specific editor settings
You can now configure language specific editor settings for multiple languages at once. The following example shows how you can customize settings for javascript and typescript languages together in your settings.json file:
See HERE for a complete list of icons and their meanings in the OUTLINE view.
The following tables shows the icons that you most commonly see in the OUTLINE view.
| Icon | Name | Symbol type |
|---|---|---|
| Methods and Functions |
method, function, constructor
|
|
| Variables |
variable
|
|
| Fields |
field
|
|
| Words |
text
|
|
| Constants |
constant
|
|
| Classes |
class
|
|
| Structures |
struct
|
|
| Modules |
module
|
|
| Properties and Attributes |
property
|
- Constant applies to Quarto sections. Need to set
"outline.showConstants": true,to show sections properly in the OUTLINE view.
R terminal launch error:
The terminal process "/Users/menghan/.local/bin/radian '--no-save', '--no-restore'" terminated with exit code: 1.
Check if can run
if it starts fine, then it is an environment issue, i.e., missing PATH problem.
Fix: Add to settings.json:
"terminal.integrated.env.osx": {
"PATH": "/usr/local/bin:/Library/TeX/texbin:/Applications/quarto/bin:${env:HOME}/.local/bin:${env:PATH}"
}This expands the PATH for the integrated terminal in VS Code, so that it can find R and radian.
Explanation:
VS Code being launched from the Dock (
launchdnever reads~/.zprofile), inheriting only the bare launchd PATH.launchd → VS Code (`PATH=/usr/bin:/bin:/usr/sbin:/sbin`) → radian ❌ inherits thatR exists in
/usr/local/bin/R, but that is not in the launchd PATH. So radian cannot find R and fails to start.Launching with
code .from a terminal sidesteps the entire class of problem, since VS Code then inherits your real environment.Terminal.app → zsh -l → reads profiles, builds PATH → radian ✅ inherits full PATHChanging
terminal.integrated.env.osxadds the four directories to VS Code’s own PATH. But it is static. If you change your PATH in your shell profile (e.g.,~/.zprofile), VS Code will not see the change until you updateterminal.integrated.env.osxagain.If you’d rather have it self-maintaining, the alternative is pointing
r.rterm.macat a#!/bin/zsh -lwrapper that execs radian.
To let r.rterm.mac point to a wrapper script, create a file ~/.local/bin/radian-vscode:
chmod +x it, and set "r.rterm.mac": "/Users/menghan/.local/bin/radian-vscode" in settings.json.
radian now inherits whatever your login files produce at the moment you open the terminal, so it stays correct on its own.
Reading it piece by piece:
#!/bin/zsh -l: VS Code launches this file; the kernel starts/bin/zshwith-l, making it a login shell, so it reads~/.zshenv,~/.zprofile,~/.zloginand builds your real PATH.exec: replaces the zsh process with radian rather than spawning a child. No leftover shell wrapping your session, soq(), Ctrl-D, and signals behave exactly as they do now."\$@": forwards the--no-save --no-restorethat the extension appends.
References:
- R in Visual Studio Code
- Set up
vscode-R: - Getting started with
httpgd: https://nx10.github.io/httpgd/articles/getting-started.html - Bookdown in VS code: https://www.bendirt.com/bookdown/
- Jupyter Notebooks in VS Code