7 Keyboard Shortcuts
Keyboard shortcuts tend to make our lives easier. Some that you might already be familiar with in day to day life include quickly saving (Cmd + S or Ctrl + S), or Undo (Cmd + Z or Ctrl + Z).
There are many keyboard shortcuts that you can access in R, this section provides a brief tour of them, and why you might want to use them.
7.1 Overview
- Teaching 5 minutes
- Exercises 5 minutes
7.2 Questions
- What sort of keyboard shortcuts should I care about?
7.3 Objectives
7.4 Gifs of the action
7.4.1 Knit document
7.4.2 Insert Chunk
7.4.3 Run Current Chunk
7.4.4 Jump to
7.4.5 Create multiple cursors
7.4.6 Delete the current line
7.4.7 Un/Comment out a line
7.4.8 Reformat Section
7.4.9 Show Keyboard Shortcut Reference
7.5 Table of Common Shortcuts
Below is a small table of tasks you can perform with keyboard
Action | Windows/Linux | Mac |
---|---|---|
Knit document | Ctrl + Shift + K | Cmd + Shift + K |
Insert Chunk | Ctrl + Alt + I | Cmd + Option + I |
Run Current Chunk | Ctrl + Alt + C | Cmd + Option + C |
Jump to Shift+Alt+J | Cmd+Shift+Option+J | |
Show Keyboard Shortcut Reference | Alt+Shift+K | Option+Shift+K |
Create multiple cursors | Ctrl + Alt + Up/Down | option + control + Up/Down |
Delete the current line | Ctrl + D | Cmd + D |
Un/Comment out a line | Ctrl + Shift + C | Cmd + Shift + C |
Reformat Section | Ctrl + Shift + A | Cmd + Shift + A |
7.6 Further Reading
- The https://www.rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf has an index of shortcuts.
- This [https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts] help file has a guide to customising keyboard shortcuts.
7.7 Your Turn
- Using the Keyboard Shortcut Reference, find the keyboard shortcut for inserting a pipe character ( %>% )
- Spend 3 minutes practicing these commands in a document.