⌥+⌃AltPlusCtrl

RStudio Keyboard Shortcuts

RStudio's shortcuts are shaped by its four-pane layout — source editor, console, environment/history, and files/plots/packages/help — and a large chunk of the bindings exist specifically to move focus between those panes or execute code from the editor straight into the console without touching the mouse. Running code is the single most-repeated action in any R session, so the shortcut for sending the current line or selection to the console is arguably the most important one in the entire application, used dozens of times per hour during active analysis work. On Mac, a handful of the code-execution bindings stay on Ctrl rather than switching to Cmd, a carryover from RStudio's cross-platform Qt-based interface that catches people used to every shortcut swapping cleanly to Cmd. Code chunks matter specifically for anyone working in R Markdown or Quarto rather than a plain .R script, since that notebook-style document format interleaves narrative writing with executable code blocks, and RStudio's chunk-insertion and chunk-execution shortcuts exist precisely to support that mixed-document workflow alongside the plain-script execution shortcuts documented above.

Code Execution

ActionWindowsMacDescription
Run current line or selectionCtrl+EnterCmd+ReturnSends the current line (or selected block) from the source editor to the console for execution, the single most-used shortcut in RStudio by a wide margin during interactive analysis.
Source entire scriptCtrl+Shift+SCmd+Shift+SRuns the entire active script file from top to bottom in one action, as opposed to line-by-line execution, useful for re-running a complete analysis pipeline after an edit.
Restart R sessionCtrl+Shift+F10Cmd+Shift+F10Terminates and restarts the underlying R process, clearing all loaded packages and objects from memory — the standard fix for a session that's accumulated stale state or a memory leak from a long analysis session.
Interrupt running commandEsc (console focused)EscHalts whatever command is currently running in the console, the fix when a loop or function call has clearly overstayed its expected runtime or looks frozen.
Run current code chunkCtrl+Shift+EnterCmd+Shift+ReturnExecutes every line within the current R Markdown or Quarto code chunk at once, distinct from running a single line, rendering that chunk's output inline beneath the code within the document.

Pane Navigation

ActionWindowsMacDescription
Move focus to Console paneCtrl+2Ctrl+2Jumps keyboard focus directly to the Console pane, useful after typing code in the Source pane and wanting to interact with console output or history without a mouse click.
Move focus to Source paneCtrl+1Ctrl+1Returns keyboard focus to the Source editor pane, the reverse companion to jumping into the Console.
Switch to next source tabCtrl+F11Ctrl+F11Cycles to the next open file tab in the Source pane, useful when working across several script files in the same project.
Zoom (maximize) current paneCtrl+Shift+1 through 4Cmd+Shift+1 through 4Temporarily expands a single pane (Source, Console, Environment, or Files/Plots) to fill the entire window, useful for reviewing a large plot or dense console output without the other panes' clutter, then toggling back.

Editing

ActionWindowsMacDescription
Comment/uncomment lineCtrl+Shift+CCmd+Shift+CToggles a leading # comment character on the current line or all selected lines, standard for quickly disabling a block of code without deleting it.
Reformat codeCtrl+Shift+ACmd+Shift+AAutomatically reformats the current selection's indentation and spacing according to RStudio's built-in style rules, useful for cleaning up code pasted from elsewhere with inconsistent formatting.
Insert pipe operatorCtrl+Shift+MCmd+Shift+MInserts the pipe operator (%>% from magrittr, or |> for the native R pipe depending on your configured preference) at the cursor, central to writing readable chained data-transformation code in the tidyverse style.
Find and ReplaceCtrl+FCmd+FOpens the find-and-replace panel scoped to the active source document, supporting regex-based search patterns for more complex find-and-replace operations across a script.
Insert code chunk (R Markdown/Quarto)Ctrl+Alt+ICmd+Option+IInserts a new executable code chunk at the cursor within an R Markdown or Quarto document, the fundamental building block of a notebook-style document mixing narrative text with runnable R code and its inline output.

Frequently Asked Questions

Why does Ctrl+Enter still use Ctrl on Mac instead of Cmd?

Run Current Line is one of the specific RStudio shortcuts that keeps Ctrl even on Mac rather than following the usual Cmd substitution pattern, a legacy convention carried over from RStudio's early cross-platform design decisions. It's worth deliberately memorizing as an exception since it's used so constantly, and it's easy to instinctively reach for Cmd+Return out of habit from other Mac-native code editors.

What's the real difference between the native pipe (|>) and magrittr's pipe (%>%)?

The native pipe was added directly to R itself in version 4.1 and requires no external package, while %>% comes from the magrittr package (loaded automatically by the tidyverse). They behave similarly for most simple chains, but differ in some edge cases around placeholder arguments and function calls — which one Ctrl+Shift+M inserts depends on a setting in RStudio's Code preferences, and older scripts or tutorials predating R 4.1 will consistently use %>% since the native pipe didn't exist yet.

Why does restarting the R session sometimes not fix a stuck script?

Restart R session clears the R process's memory and loaded packages, but it does not stop or reset external processes your code may have started (a background database connection, a long-running system call via a shell command, or a stuck plot device), so a script hung on an external resource sometimes needs that resource addressed separately rather than just an R session restart.

Why does sending code to the console with Ctrl+Enter sometimes run more than just the current line?

If the current line is part of a multi-line statement — an unclosed function call, a pipe chain spanning several lines with %>% or |>, or an if block — RStudio is smart enough to detect that the statement is incomplete and sends the entire logical statement to the console rather than just the single line the cursor happens to sit on, since running a fragment of an incomplete expression would just produce a syntax error. This can look surprising the first time you see several lines execute from a single keypress, but it is deliberate behavior designed to match how R actually parses multi-line expressions rather than a bug.

Is there a way to see a live preview of a data frame or plot without leaving the source pane?

RStudio's built-in Viewer pane, along with inline chunk output when working inside an R Markdown or Quarto document, renders tables and plots directly beneath the code that generated them without switching focus away from the source editor at all, which is one of the more genuinely useful features distinguishing notebook-style RStudio work from plain script-based console work, especially for iterative data exploration where you want to see a result immediately after each small change rather than checking a separate Plots pane every time. Data scientists coming from a plain script-editor background often find this the biggest quality-of-life improvement once they get used to relying on it during exploratory analysis work.

What is a code chunk, and how is running one different from Run Current Line?

A code chunk is a fenced block of executable R code embedded within an R Markdown or Quarto document, distinguishable from surrounding narrative text — running a chunk (Ctrl+Shift+Enter) executes every line inside that chunk together and renders the combined output inline beneath it, while Run Current Line executes only a single line or selection regardless of whether it happens to sit inside a chunk, which matters when a chunk contains several interdependent lines that need to run together as a unit.