Settings and Extensions

Your Positron experience can be customized through settings at either the user or workspace level and by installing extensions. This is not a comprehensive guide to all the ways you can customize Positron, most of which are inherited from VS Code, but rather a targeted look at what we think is most relevant for users coming from RStudio.

Settings for RStudio users

Positron includes hundreds of configurable settings, but the following are particularly helpful for RStudio users transitioning to Positron.

RStudio keybindings

To opt in to the RStudio keybindings (recommended at the user level):1

{
   "workbench.keybindings.rstudioKeybindings": true
}

Opting in does overwrite some of Positron’s default keybindings, so you might then wish to update or remove some of these newly enabled RStudio keybindings.

Whitespace and newlines

To enable behavior similar to RStudio’s (recommended at the user level):

{
   "files.trimTrailingWhitespace": true,
   "files.insertFinalNewline": true,
   "files.trimFinalNewlines": true,
}

You can additionally control how these (or other) settings are applied to specific file types, such as markdown files:

{
   "[markdown]": {
      "files.trimTrailingWhitespace": false
   }
}

File type specific settings take precedence over the general settings.

Settings from extensions

Be aware that in addition to Positron itself, extensions also provide configurable settings. For example, you can change the look of cells in a Quarto document (recommended at the user level):

{
   "quarto.cells.background.color": "useTheme",
}

Or you can control how markdown is wrapped in the Quarto visual editor (recommended at the workspace level):

{
   "quarto.visualEditor.markdownWrap": "sentence",
}

Format on save

You can opt into formatting your R code every time you save a file, using Air (recommended at the workspace level):

{
   "[r]": {
      "editor.formatOnSave": true
   }
}

Read more about formatting R code with Air.

Extensions for RStudio users

You can use extensions to customize your IDE theme. For example, install Tomorrow Night Bright (R Classic) for an RStudio theme that has been ported to Positron.2

You can use extensions to customize other details of your code editing experience, beyond the theme. For example, install Indent-Rainbow for colorized indentation or Rainbow CSV for colorized CSV files.

You can use extensions to add functionality for interacting with services you use. For example, install GitHub Actions to interact with GitHub Actions from your IDE or GitLab Workflow for GitLab support.

Note

Positron doesn’t currently bundle the Shiny extension, so you will need to install that if you want to use it.

Extending Positron yourself

Positron provides shims for much of the functionality available via the rstudioapi package, which allows you to control and extend Positron programmatically from R. For example, you can use rstudioapi::restartSession() to restart the active R session. Since Positron does not provide a full implementation of all RStudio API methods, use rstudioapi::hasFun() to defensively check if a method is implemented before calling it.

You can also create your own extensions for Positron. This is a powerful way to add custom functionality or integrate with other tools and services. Creating an extension is more involved than creating an RStudio addin and does require some knowledge of TypeScript/JavaScript, but extensions can customize the behavior of Positron is ways that have never been possible for RStudio.

For a general approach to detect if your R code is running inside Positron, use Sys.getenv("POSITRON").

Footnotes

  1. The use of workbench here in this setting name refers to the overall Code OSS UI.↩︎

  2. Learn how you can create a theme extension like this yourself.↩︎