This post is part of a series on new features in RStudio 1.4, currently available as a preview release.
Just as a paint palette gives the artist instant access to all their colors, a command palette is a software affordance that gives instant, searchable access to all of a program’s commands. RStudio 1.4 introduces this very popular tool to our workbench.
Command palettes have become a fixture of modern IDEs, and with good reason. They improve:
The palette can be invoked with the keyboard shortcut Ctrl + Shift + P (Cmd + Shift + P on macOS).
It’s also available on the Tools menu (Tools -> Show Command Palette).
RStudio’s command palette has three main types of content:
First and foremost, the command palette serves as a way to search for and invoke RStudio commands quickly with just a few keystrokes. Every RStudio command is in the palette, unless it’s been explicitly hidden in the current mode.
To find a command, enter a word or short sequence of characters from the command. For example, to create a new script, start typing
You can keep typing to filter the list, or press Up/Down to choose a command from the list and then Enter to execute the chosen command. Commands are displayed with their bound keyboard shortcuts, if any, so that you know how to invoke the command directly with the keyboard next time.
If your command doesn’t have a shortcut, you can use the Modify Keyboard Shortcuts command to add one.
In addition to all of RStudio’s commands, the command palette provides easy access to most of its settings. You’ll see the word
Setting in front of settings, along with a small control that allows you to change the setting.
For example, you can turn RStudio’s code margin indicator off and on or move it to a different column. If you have a code editor open, you’ll see these changes reflected in real time as you make them.
Note that the settings displayed are your personal (user-level) settings. Just like the settings in Global Options, they can be overridden by project-level settings, and some settings don’t take effect until after a restart.
Finally, the command palette shows all of the commands exposed by any installed RStudio add-ins. You can find these by typing any part of the add-in name and/or part of the command. For example, to use a command from the excellent styler addin:
This makes the palette user-extensible; if you want to add your own commands to the palette, you can create an RStudio Addin to do so with just a few lines of code, or use the shrtcts addin to do so in even fewer lines of code!
The command palette’s search syntax is simple; it looks for complete matches for each space-separated term you enter. So, for example, a query for
new proj will find all of the entries that contain the term
new AND the term
In the future, we hope to improve the matching heuristics by prioritizing complete matches and recently or frequently used commands.
In this series, we walk through lesser-known tips and tricks to help you work more effectively and efficiently in R Markdown. This third post focuses on features that save you time and trouble.
The RStudio IDE includes a visual markdown editor that displays changes in real-time and provides support for technical writing. This post walks through several features of visual editing mode.