-
Notifications
You must be signed in to change notification settings - Fork 130
Recommended extensions and configuration
In addition to the setup detailed in the Getting Started page, or the configuration available in the settings page, users may be interested in further configuration to match the experience of other editors like RStudio. Many of these are features that vscode-R does not directly control, but are possible to handle through VSCode and the libraries vscode-R interfaces with. We suggest some of those options here.
User's settings.json
file in VSCode can be configured to format on save:
{
"[r]": {
"editor.defaultFormatter": "REditorSupport.r",
"editor.formatOnSave": true
},
"[rmd]": {
"editor.defaultFormatter": "REditorSupport.r",
"editor.formatOnSave": true
}
}
It's also useful to set some sensible defaults for the R linter. These can be
configured in a .lintr
file at your computer's HOME
directory (or
USERPROFILE
if you are on Windows), or in your current project.
The following example allows commented code, which is often a necessity, and prevents checking if objects are in global scope, since this can throw extraneous errors if functions from libraries are called.
linters: with_defaults(
object_usage_linter = NULL,
commented_code_linter = NULL)
See the
lintr
docs
for more configuration details and rules.
Treat names.like.this
as one word for selection.
In VSCode's settings.json
, add the following:
"[r]": {
"editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?"
}
We recommend the C/C++ VSCode extension with the following settings to write Rcpp:
In .vscode/c_cpp_properties.json
:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${env:HOME}/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include",
"/usr/share/R/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
.clang-format
:
---
Language: Cpp
BasedOnStyle: LLVM
Standard: Cpp11
ReflowComments: false
---
In your settings.json
:
"C_Cpp.commentContinuationPatterns": [
"/**",
"//'"
]
See demonstration and more tooling at renkun-ken/vscode-rcpp-demo
We recommend the VSCode extension
Path Autocomplete
with the following configuration in settings.json
to enable autocompletion for
file names:
"path-autocomplete.pathMappings": {
"/": "/",
"./": "${folder}"
}
You can use the Error Lens extension for more visible error messages.
- Getting Started
- Installation
- Configuration
- Features
- Package development
- R Markdown
- Contributing
- FAQ