---
title: "Custom Shortcuts"
date-meta: 2022-12-12
---

Users can customize or bind keyboard shortcuts to execute:  

- RStudio application commands 
- Editor commands 
- User defined R functions 
- [RStudio Addins](https://rstudio.github.io/rstudioaddins/) or the [`shrtcts`](https://pkg.garrickadenbuie.com/shrtcts/) package

Access the keyboard shortcuts from the RStudio menu: **Tools** \> **Modify Keyboard Shortcuts**:

![](images/keyboard-shortcuts.png){fig-alt="A screenshot of the Tools menu bar highlighting the Modify Keyboards Shortcuts" width="300"}

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).

![](images/keyboard-shortcut-table.png){fig-alt="A screenshot of the available keyboard shortcuts."}

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.

![](images/modify-shortcut.png){fig-alt="A screenshot of a customized shortcut"}

If a mistake was made, press <kbd>Backspace</kbd> to clear a single key combination, or <kbd>Delete</kbd> 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. <kbd>Ctrl+Alt+F</kbd>, or also to a sequence of keys, as in <kbd>Ctrl+X Ctrl+F</kbd>.

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:

![](images/filter-shortcut.png){fig-alt="A screenshot of the keyboard shortcut wizard filtered to 'reflow'"}

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:

![](images/masked-shortcut.png){fig-alt="A screenshot of a 'masked' shortcut which indicates the conflict with 'Clear Console'"}

If two commands are bound to the same key sequence, then that conflict will be highlighted and displayed in yellow.

![](images/shortcut-conflict.png){fig-alt="A screenshot of a shortcut conflict, displaying the specific command it conflicts with."}

## 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
