7 Keyboard Shortcuts
Keyboard shortcuts tend to make our lives easier. Some that you might already be familiar with in day to day life are: quickly saving (Cmd + S or Ctrl + S), or Undo (Cmd + Z or Ctrl + Z).
There are many keyboard shortcuts 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 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.5 Further Reading
- The Rstudio Cheat Sheet has an index of shortcuts.
- This help file has a guide to customising keyboard shortcuts.
- The shrtcts R package for creating new shortcuts.
Your Turn
- In your awesome quarto document
- Oractice using the Keyboard Shortcut Reference and find the keyboard shortcut for inserting a pipe character (
%>%
or|>
) - Spend 3 minutes practicing these commands.
- Oractice using the Keyboard Shortcut Reference and find the keyboard shortcut for inserting a pipe character (
- Ask Nick to demonstrate some of his favourite shortcut combos