Positron Setup

This page is not meant to be an exhaustive guide to setting up Positron, but rather a collection of setup hints that are easy to miss if you do not already know them.

Quarto extension

At the time of writing, the most recent Quarto extension version, 1.131.0, introduces a noticeable delay when executing code from an .Rmd document with Cmd/Ctrl + Enter while the cursor is inside a code chunk: it can take around a second before the code is actually sent to the console. Executing selected code is not affected in the same way. This seems to be an issue with the extension implementation rather than Positron more generally or our system configuration, and an older extension version does not show the same slowdown. To install the older version, open the Quarto extension page in Positron, click the dropdown next to Uninstall, choose Install Specific Version…, select 1.116.0, and install it.

Exporting and importing profiles

Because Positron is built on VS Code, it has many configuration options. The main ones are layout, theme, and keyboard shortcuts, but there are others as well. Instead of setting everything up from scratch, you can import someone else’s profile. You can also export your local Positron profile and import it into Positron Workbench. The easiest way to export and import is via GitHub Gists.

To export a profile:

  1. Click the gear icon (top right or bottom left).
  2. Click Profiles.
  3. On the profiles page, click the three-dots menu next to the profile you want to export (you may have just one Default profile or many), then click Export.
  4. Name the profile and press Enter.
  5. Select GitHub Gist and follow the prompts. At the end, you will get a gist in your GitHub profile. It will be a one-line JSON file that fully describes your profile.

To import a profile:

  1. Go to Profiles again (gear icon -> Profiles).
  2. Click the down arrow on the New Profile button, then click Import Profile.
  3. Paste the GitHub Gist URL and press Enter.

Example profile you can import: link.

Environment variables in terminal

The R session in the Session tab will automatically have all environment variables defined in your ~/.Renviron. Terminals in Positron in the Terminal tab, unlike in RStudio, will not have them by default. To fix this, add the following to your ~/.bashrc:

if [ -f "$HOME/.Renviron" ]; then
  set -a
  source "$HOME/.Renviron"
  set +a
fi

Keyboard Shortcuts

Keyboard shortcuts are keybindings that run commands in Positron so you can trigger actions quickly without menus.

How to set them up

  1. Open the Command Palette.
  2. Run Open Keyboard Shortcuts (JSON).
  3. Paste the block below into the array in keybindings.json.
  4. Save the file.

Example: g6tr_project_continue() on Ctrl+Shift+L

{
  "key": "ctrl+shift+l",
  "command": "workbench.action.executeCode.console",
  "when": "(editorTextFocus || positronConsoleFocused) && !isRPackage",
  "args": {
    "langId": "r",
    "code": "if (isTRUE(g6tr:::g6tr_is_project('.'))) g6tr::g6tr_project_continue()",
    "focus": true
  }
}

Fields explained

  • key: The keystroke that triggers the binding.
  • command: The command Positron runs. workbench.action.executeCode.console sends code to the Console.
  • when: A condition that must be true for the binding to fire. editorTextFocus || positronConsoleFocused enables it in editor or Console, and !isRPackage avoids overriding the default package-load shortcut.
  • args.langId: The language runtime to use (r).
  • args.code: The R code to execute. Here we guard with g6tr:::g6tr_is_project('.') so it only runs in a g6tr project.
  • args.focus: If true, focus stays on the Console after execution.