Custom Shortcuts
Users can customize or bind keyboard shortcuts to execute:
- RStudio application commands
- Editor commands
- User defined R functions
- RStudio Addins or the
shrtcts
package
Access the keyboard shortcuts from the RStudio menu: Tools > Modify Keyboard Shortcuts:
Selecting Modify Keyboard Shortcuts will display available editor commands (commands that affect the current document’s contents, or the current selection), alongside RStudio commands (commands whose actions are scoped beyond just the current editor).
Each row represents a particular command binding:
- The command’s Name
- The keyboard Shortcut it is bound to
- The Scope where that binding is active
Modify a command’s shortcut by clicking on the cell containing the current shortcut key sequence, and typing the new sequence to bind the command to. As you type, the current row will be marked to show that the binding has been updated, and the shortcut field will be updated based on the keys entered.
If a mistake was made, press Backspace to clear a single key combination, or Delete to reset that binding to the original value it had when the widget was opened.
Commands can be either a single ‘key chord’; e.g. Ctrl+Alt+F, or also to a sequence of keys, as in Ctrl+X Ctrl+F.
You can also filter, based on the names of commands, by typing within the Filter… search box at the top left, to more easily find commands of interest:
After a keyboard shortcut has been modified, press Apply and the shortcuts will be applied to the current session and saved for future sessions.
Handling conflicts
By default, RStudio application command bindings will override editor command bindings. If an editor command and an RStudio command are both bound to the same key sequence, the RStudio command will take precedence and the editor command will not be executed. Editor commands that are masked by an RStudio command will be crossed out and have a small icon showing the masking command:
If two commands are bound to the same key sequence, then that conflict will be highlighted and displayed in yellow.
Saving and loading
The RStudio keybindings are saved as JSON files in the directory ~/.R/rstudio/keybindings/
-- the bindings for the editor and RStudio itself at:
RStudio 1.3, and later (Windows)
~/AppData/Roaming/RStudio/keybindings/rstudio_bindings.json
~/AppData/Roaming/RStudio/keybindings/editor_bindings.json
RStudio 1.3, and later (MacOS/Linux)
~/.config/rstudio/keybindings/rstudio_bindings.json
~/.config/rstudio/keybindings/editor_bindings.json