Appendix D — Helpful shortcuts

Table D.1: Different OS, different keys
Key in Windows/Linux Key in Mac
CTRL Command Key
Alt Option Key
Table D.2: Helpful shortcuts
Action Shortcut Keys Description
Run code Ctrl + Enter Runs the current line and jumps to the next one, or runs the selected part without jumping further.
Alt + Enter Allows running code without moving the cursor to the next line if you want to run one line of code multiple times without selecting it.
Ctrl + Alt + R Runs the entire script.
Ctrl + Alt + B/E Run the script from the Beginning to the current line and from the current line to the End.
Write code Alt + (-) Inserts the assignment operator (<-) with spaces surrounding it.
Ctrl + Shift + M Inserts the magrittr/pipe operator (%>%) with spaces surrounding it.
Ctrl + Shift + C Comments out code by putting a # in front of each line of marked code of a script.
Ctrl + Shift + R Creates a foldable comment section in your code.
Navigating in RStudio Ctrl + 1 Move focus to editor.
Ctrl + 2 Move focus to console.
Ctrl+Tab and Ctrl+Shift+Tab to switch between tabs.
Ctrl + Shift + N Open a new R script.
Ctrl + w Close a tab.