Keyboard Shortcuts
Positron’s keyboard shortcuts, with a few exceptions, are a superset of the keyboard shortcuts used by Visual Studio Code. This table lists the shortcuts specifically added for Positron.
Our documentation shows you keyboard shortcuts based on your operating system. For example, if you visit this page using Windows, you will see keyboard shortcuts for Windows. Hover your mouse over the keyboard shortcut to see the information for other platforms.
Global shortcuts
Shortcut | Description |
---|---|
Run the selected code in the editor; if no code is selected, run the current statement | |
Restart the interpreter currently open in the Console | |
Run the file open in the editor (using e.g. source() or %run ) |
|
F1F1 |
Show contextual help for the topic under the cursor |
, | Show contextual help for the topic under the cursor (alternate binding) |
, FF | Focus the Console |
, VV | Focus the Variables pane |
Ctrl-LCtrl-L |
Clear the Console |
R shortcuts
Shortcut | Description |
---|---|
Insert the pipe operator (|> or %>% ) |
|
Insert the assignment operator (<- ) |
|
source() the current R script |
|
, HH | Insert section |
Load the current R package, if any, with devtools::load_all() |
|
Build and install the current R package, if any | |
Test the current R package, if any | |
Check the current R package, if any | |
Document the current R package, if any |
If you’d prefer to use RStudio keybindings, learn how to enable them in Positron.
Custom shortcuts
Because Positron is built on top of VS Code, you can use its infrastructure for defining custom keybindings. You can use this infrastructure with any Positron-specific commands, such as workbench.action.executeCode.console
or workbench.action.executeCode.silently
.
As a specific example, you could add the following to your user keybindings.json
(access this file from the Command Palette with Open Keyboard Shortcuts (JSON)) to make a keyboard shortcut to create a reprex from your current selection:
{
"key": "Cmd+Shift+R",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "reprex::reprex_selection()",
"focus": true
}
}
Troubleshooting
If you are puzzled by the behaviour of a keyboard shortcut, here are two issues to consider:
- Context: Many keyboard shortcuts are only enabled in certain contexts, such as when editing code or when working in an R package. Consider if you might be invoking the shortcut in an unexpected and unsupported context.
- Conflicts: A keyboard shortcut can have multiple associations across different situations or extensions. When a shortcut is associated with more than one command, a priority system determines which command wins and the result might not be what you expect.
The command Preferences: Open Keyboard Shortcuts opens an interface that is a great way to investigate keyboard shortcut mysteries.
Be aware that Positron’s integrated terminal can intercept some keyboard shortcuts. You can set up a keybinding to skip the shell by specifying its command in the terminal.integrated.commandsToSkipShell
setting, either via the settings UI or by editing settings.json
:
{
"terminal.integrated.commandsToSkipShell": [
// Ensure the keyboard shortcut for focusing the console skips the shell
"workbench.action.positronConsole.focusConsole"
]
}