-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathkeyboard-shortcuts.qmd
More file actions
63 lines (49 loc) · 4.08 KB
/
keyboard-shortcuts.qmd
File metadata and controls
63 lines (49 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: "Keyboard Shortcuts"
description: "Master Positron's keyboard shortcuts for running code, navigating panes, and accessing help. Includes custom keybinding options and troubleshooting tips."
---
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.
::: {.callout-note}
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.
:::
| Shortcut | Description |
| -------- | ----------- |
| {{< kbd mac=Command-Enter win=Ctrl-Enter linux=Ctrl-Enter >}}| Run the selected code in the editor; if no code is selected, run the current statement |
| {{< kbd mac=Command-Alt-Home win=Ctrl-Alt-Home linux=Ctrl-Alt-Home >}} | Run code from document beginning to current line |
| {{< kbd mac=Command-Alt-End win=Ctrl-Alt-End linux=Ctrl-Alt-End >}} | Run code from current line to document end |
| {{< kbd mac=Command-Shift-0 win=Ctrl-Shift-0 linux=Ctrl-Shift-0 >}} | Restart the interpreter currently open in the Console |
| {{< kbd mac=Command-Shift-Enter win=Ctrl-Shift-P linux=Ctrl-Shift-P >}} | Run the current file in the Console (using e.g., `source()` for `.R` or `%run` for `.py`) |
| {{< kbd F1 >}} | Show contextual help for the topic under the cursor |
| {{< kbd mac=Command-K win=Ctrl-K linux=Ctrl-K >}}, {{< kbd mac=Command-R win=Ctrl-R linux=Ctrl-R >}} | Show contextual help for the topic under the cursor (alternate binding) |
| {{< kbd mac=Command-K win=Ctrl-K linux=Ctrl-K >}}, {{< kbd F >}} | Focus the Console |
| {{< kbd mac=Command-K win=Ctrl-K linux=Ctrl-K >}}, {{< kbd V >}} | Focus the Variables pane |
| {{< kbd Ctrl-L >}} | Clear the Console |
## Custom shortcuts
Because Positron is built on top of VS Code, you can use [its infrastructure for defining custom keybindings](https://code.visualstudio.com/docs/getstarted/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:
```json
{
"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](https://code.visualstudio.com/docs/configure/keybindings) that is a great way to investigate keyboard shortcut mysteries.
Be aware that Positron's integrated terminal can [intercept some keyboard shortcuts](https://code.visualstudio.com/docs/terminal/advanced#_keyboard-shortcuts-and-the-shell). You can set up a keybinding to skip the shell by specifying its command in the [`terminal.integrated.commandsToSkipShell`](positron://settings/terminal.integrated.commandsToSkipShell) setting, either via the settings UI or by editing `settings.json`:
```json
{
"terminal.integrated.commandsToSkipShell": [
// Ensure the keyboard shortcut for focusing the console skips the shell
"workbench.action.positronConsole.focusConsole"
]
}
```