8  Keyboard Shortcuts

For a scientific report to be completely credible, it must be reproducible. The full computational environment used to derive the results, including the data and code used for statistical analysis should be available for others to reproduce. quarto is a tool that allows you integrate your code, text and figures in a single file in order to make high quality, reproducible reports. A paper published with an included quarto file and data sets can be reproduced by anyone with a computer.

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

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.