RStudio cheat sheet

112 shortcuts in 15 lessons

Reading a list won't make them stick. ShortcutFoo has you type each shortcut, then brings it back just before you'd forget it.

Console I

7 shortcuts
  • ^2
    Move cursor to console
  • ^L
    Clear console
  • ⌘LEFT
    Move cursor to beginning of line
  • ⌘RIGHT
    Move cursor to end of line
  • ⌘UP
    Popup command history
  • ESC
    Interrupt currently executing command
  • ^⇧H
    Change working directory

Source I

7 shortcuts
  • ^.
    Goto file/function
  • ^1
    Move cursor to source editor
  • ⌘⇧K
    Compile
  • ⌘⌥I
    Insert chunk (Sweave and Knitr)
  • ⌘⇧R
    Insert code section
  • ⌘↵
    Run current line / selection
  • ⌥↵
    Run current line / selection (retain cursor position)

Source II

7 shortcuts
  • ⌘⇧P
    Re-run previous region
  • ⌘⌥R
    Run current document
  • ⌘⌥B
    Run from beginning of document to current line
  • ⌘⌥E
    Run from current line to end of document
  • ⌘⌥F
    Run the current function definition
  • ⌘⌥T
    Run the current code section
  • ⌘⌥P
    Run previous Sweave / Rmd code

Source III

8 shortcuts
  • ⌘⌥C
    Run current Sweave / Rmd chunk
  • ⌘⇧O
    Source a file
  • ⌘⇧S
    Source the current document
  • ⌘⇧↵
    Source the current document (with echo)
  • ⌘⌥L
    Fold selected
  • ⌥⇧L
    Unfold selected
  • ⌘⌥O
    Fold all
  • ⌘⌥⇧O
    Unfold all

Source IV

7 shortcuts
  • ⌘⌥⇧G
    Go to line
  • ⌘⌥⇧J
    Jump to
  • ^⇧.
    Switch to tab
  • ^F11
    Previous tab
  • ^F12
    Next tab
  • ^⇧F11
    First tab
  • ^⇧F12
    Last tab

Source V

7 shortcuts
  • ⌘F9
    Navigate back
  • ⌘F10
    Navigate forward
  • ⌘⌥X
    Extract function from selection
  • ⌘⌥V
    Extract variable from selection
  • ⌘I
    Reindent lines
  • ⌘⇧A
    Reformat selection
  • ⌘⌥⇧P
    Show diagnostics

Source VI

8 shortcuts
  • ^T
    Transpose letters
  • ⌥UP
    Move lines up
  • ⌥DOWN
    Move lines down
  • ⌘⌥UP
    Copy lines up
  • ⌘⌥DOWN
    Copy lines down
  • ^P
    Jump to matching brace / parenthesis
  • ^⇧E
    Expand to matching brace / parenthesis
  • ^⌥⇧E
    Select to matching brace / parenthesis

Source VII

10 shortcuts
  • ^⌥UP
    Add cursor above current cursor
  • ^⌥DOWN
    Add cursor below current cursor
  • ^⌥⇧UP
    Move active cursor up
  • ^⌥⇧DOWN
    Move active cursor down
  • ⌘F
    Find and replace
  • ⌘G
    Find next
  • ⌘⇧G
    Find previous
  • ⌘E
    Use selection for find
  • ⌘⇧J
    Replace and find
  • ⌘⇧F
    Find in files

Editing I

7 shortcuts
  • ⌥LEFT
    Move to previous word
  • ⌥RIGHT
    Move to next word
  • ⌘UP
    Move to start
  • ⌘DOWN
    Move to end
  • ⌘D
    Delete line
  • ⌥⇧LEFT
    Select word to left
  • ⌥⇧RIGHT
    Select word to right

Editing II

7 shortcuts
  • ⌘⇧LEFT
    Select to line start
  • ⌘⇧RIGHT
    Select to line end
  • ⌘⇧UP
    Select to start
  • ⌘⇧DOWN
    Select to end
  • ⌥BACKSPACE
    Delete word left
  • ^K
    Delete to line end
  • ^⌥BACKSPACE
    Delete to line start

Editing III

10 shortcuts
  • ⇧TAB
    Outdent
  • TAB
    Indent
  • ^U
    Yank line up to cursor
  • ^K
    Yank line after cursor
  • ^Y
    Insert currently yanked text
  • ⌥-
    Insert assignment operator
  • ⌘⇧M
    Insert pipe operator
  • F1
    Show help for function at cursor
  • F2
    Show source code for function at cursor
  • ⌘⌥U
    Find usages for symbol at cursor (c++)

Views I

11 shortcuts
  • ^1
    Move focus to source editor
  • ^2
    Move focus to console
  • ^3
    Move focus to help
  • ^4
    Show history
  • ^5
    Show files
  • ^6
    Show plots
  • ^7
    Show packages
  • ^8
    Show environment
  • ^9
    Show git / svn
  • ^0
    Show build
  • ⌘F8
    Sync editor and PDF preview

Build / Debug I

8 shortcuts
  • ⌘⇧B
    Build and reload
  • ⌘⇧L
    Load all (devtools)
  • ⇧F9
    Toggle breakpoint
  • F10
    Execute next line
  • ⇧F4
    Step into function
  • ⇧F6
    Finish function / loop
  • ⇧F5
    Continue
  • ⇧F8
    Stop debugging

Source Control I

4 shortcuts
  • ^⌥D
    Diff active source document
  • ^⌥M
    Commit changes
  • SPACE
    Stage / Unstage (Git)
  • ↵
    Stage / Unstage and move to next (Git)

Misc I

4 shortcuts
  • F7
    Check spelling
  • ⌘⌥F11
    Previous plot
  • ⌘⌥F12
    Next plot
  • ⌘⇧F10
    Restart R session