8 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.
8.1 Overview
- Teaching 5 minutes
- Exercises 5 minutes
8.2 Questions
- What sort of keyboard shortcuts should I care about?
8.3 Objectives
8.4 Gifs of the action
8.4.1 Knit document
8.4.2 Insert Chunk
8.4.3 Run Current Chunk
8.4.4 Jump to
8.4.5 Create multiple cursors
8.4.6 Delete the current line
8.4.7 Un/Comment out a line
8.4.8 Reformat Section
8.4.9 Show Keyboard Shortcut Reference
8.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 |
8.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.
8.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.