9 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.
9.1 Overview
- Teaching 5 minutes
- Exercises 5 minutes
9.2 Questions
- What sort of keyboard shortcuts should I care about?
9.3 Objectives
9.4 Gifs of the action
9.4.1 Knit document
9.4.2 Insert Chunk
9.4.3 Run Current Chunk
9.4.4 Jump to
9.4.5 Create multiple cursors
9.4.6 Delete the current line
9.4.7 Un/Comment out a line
9.4.8 Reformat Section
9.4.9 Show Keyboard Shortcut Reference
9.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 |
9.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.
9.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.