B Short-cuts and Cheat Sheets

B.1 Keyboard Short-cuts

There are lots of quick keyboard short-cuts that will make you more efficient in programming. Here are some that I use a lot.

Table B.1: Keyboard short-cuts for moving the cursor. For mac, you can use cmd in place of ctrl.
Stroke Function
alt + up/down Move entire line or highlighted block up or down in RStudio
alt + left/right Move cursor one word to the left or right.
ctrl + up/down Move cursor to the beginning or end of the document.
ctrl + left/right Move cursor to the beginning or end of the line.

For all the above, hold down shift to simultaneously highlight word-by-word (alt) or from the cursor to the end/beginning of the line or document (ctrl). Then you can use alt + up/down to move chunks of code around your script or just press del to delete it.

Table B.2: Keyboard short-cuts to insert characters. See the RStudio IDE cheat sheet (and others, below) for more shortcuts.
Stroke Function
shift + ctrl + n Open a new document
tab Attempt auto-complete
ctrl + enter Execute command from the editor
alt + - Insert <-
shift + ctrl + m Insert %>%
shift + ctrl + c Comment/uncomment line
ctrl + z Undo
shift + ctrl + z Redo
ctrl + a Select all
ctrl + d Delete line
alt + cmd + i Insert chunk in R markdown