Appendix A — Keyboard Shortcuts Reference

This appendix provides keyboard shortcuts for the command line, Vim, Jupyter, VS Code, Positron, and RStudio; the essential shell shortcuts are also in Table 5.1 and the editor shortcuts in Table 2.3. Platform differences (macOS versus Windows/Linux) are summarized at the end in Section A.9.

A.1 Bash/Terminal Shortcuts

Navigation

Table A.1: Bash navigation shortcuts
Shortcut Action
Ctrl+A Move cursor to beginning of line
Ctrl+E Move cursor to end of line
Ctrl+B Move cursor back one character
Ctrl+F Move cursor forward one character
Alt+B Move cursor back one word
Alt+F Move cursor forward one word
Ctrl+XX Toggle between start of line and current position

Editing

Table A.2: Bash editing shortcuts
Shortcut Action
Ctrl+D Delete character under cursor (or logout if empty)
Ctrl+H Delete character before cursor (backspace)
Ctrl+W Delete word before cursor
Alt+D Delete word after cursor
Ctrl+K Delete from cursor to end of line
Ctrl+U Delete from cursor to beginning of line
Ctrl+Y Paste last deleted text (yank)
Alt+Y Cycle through previously deleted text
Ctrl+T Swap current character with previous
Alt+T Swap current word with previous
Alt+U Uppercase from cursor to end of word
Alt+L Lowercase from cursor to end of word
Alt+C Capitalize word
Ctrl+_ Undo last edit

History

Table A.3: Bash history shortcuts
Shortcut Action
↑ or Ctrl+P Previous command in history
↓ or Ctrl+N Next command in history
Ctrl+R Reverse search through history
Ctrl+S Forward search through history
Ctrl+G Cancel history search
Alt+. Insert last argument of previous command
!! Repeat last command
!$ Last argument of last command
!* All arguments of last command
!n Execute command number n from history
!string Execute most recent command starting with string
!?string Execute most recent command containing string
^old^new Replace old with new in last command

Process Control

Table A.4: Bash process control
Shortcut Action
Ctrl+C Cancel/interrupt current command
Ctrl+Z Suspend current process (move to background)
Ctrl+D End of input / logout
Ctrl+S Pause output (freeze screen)
Ctrl+Q Resume output (unfreeze screen)
Ctrl+L Clear screen (same as clear)

Completion

Table A.5: Bash completion shortcuts
Shortcut Action
Tab Autocomplete command, filename, or variable
Tab Tab Show all possible completions
Alt+? Show possible completions
Alt+* Insert all possible completions

A.2 Screen/Tmux Shortcuts

GNU Screen

Table A.6: Screen shortcuts
Shortcut Action
Ctrl+A c Create new window
Ctrl+A n Next window
Ctrl+A p Previous window
Ctrl+A " List windows
Ctrl+A 0-9 Switch to window 0-9
Ctrl+A A Rename current window
Ctrl+A d Detach from session
Ctrl+A k Kill current window
Ctrl+A S Split horizontally
Ctrl+A \| Split vertically
Ctrl+A Tab Switch between splits
Ctrl+A X Close current split
Ctrl+A [ Enter copy mode
Ctrl+A ] Paste

Tmux

Table A.7: Tmux shortcuts
Shortcut Action
Ctrl+B c Create new window
Ctrl+B n Next window
Ctrl+B p Previous window
Ctrl+B w List windows
Ctrl+B 0-9 Switch to window 0-9
Ctrl+B , Rename current window
Ctrl+B d Detach from session
Ctrl+B & Kill current window
Ctrl+B " Split horizontally
Ctrl+B % Split vertically
Ctrl+B ←→↑↓ Navigate panes
Ctrl+B x Kill current pane
Ctrl+B z Toggle pane zoom
Ctrl+B [ Enter copy mode
Ctrl+B ] Paste
Ctrl+B ? Show all shortcuts

A.3 Vim/Vi Shortcuts

Modes

Table A.8: Vim modes
Key Action
i Enter insert mode (before cursor)
a Enter insert mode (after cursor)
I Insert at beginning of line
A Insert at end of line
o Open new line below
O Open new line above
v Visual mode (character)
V Visual mode (line)
Ctrl+V Visual mode (block)
Esc Return to normal mode
: Enter command mode

Navigation

Table A.9: Vim navigation
Key Action
h j k l Left, down, up, right
w Next word
b Previous word
e End of word
0 Beginning of line
$ End of line
^ First non-blank character
gg Go to first line
G Go to last line
nG Go to line n
Ctrl+F Page forward
Ctrl+B Page backward
Ctrl+D Half page down
Ctrl+U Half page up
% Jump to matching bracket

Editing

Table A.10: Vim editing
Key Action
x Delete character
dd Delete line
dw Delete word
d$ Delete to end of line
yy Copy (yank) line
yw Copy word
p Paste after cursor
P Paste before cursor
u Undo
Ctrl+R Redo
. Repeat last command
r Replace character
cw Change word
cc Change line
>> Indent line
<< Unindent line

Saving and Quitting

Table A.12: Vim save and quit
Command Action
:w Save
:w filename Save as filename
:q Quit
:q! Quit without saving
:wq or :x Save and quit
ZZ Save and quit (normal mode)
ZQ Quit without saving (normal mode)

A.4 Nano Shortcuts

Nano (Section 5.6.2) is the friendliest terminal editor and the one this book uses for quick edits on remote machines. Its on-screen help bar writes ^ for Ctrl and M- for Alt (the “Meta” key), so ^O in the help bar means Ctrl+O here.

Table A.13: Nano shortcuts
Shortcut Action
Ctrl+O Save (“write out”); press Enter to confirm the filename
Ctrl+X Exit (prompts to save if there are unsaved changes)
Ctrl+W Search (“where is”); Alt+W finds the next match
Ctrl+\ Search and replace
Ctrl+K Cut the current line
Ctrl+U Paste the most recently cut line(s)
Ctrl+A / Ctrl+E Move to beginning / end of line
Ctrl+_ Go to a specific line (and optionally column)
Alt+U / Alt+E Undo / redo
Ctrl+C Show current cursor position (line, column)
Ctrl+G Open nano’s built-in help

A.5 Jupyter Notebook Shortcuts

Command Mode (Press Esc first)

Table A.14: Jupyter command mode shortcuts
Shortcut Action
Enter Enter edit mode
A Insert cell above
B Insert cell below
X Cut cell
C Copy cell
V Paste cell below
Shift+V Paste cell above
D D Delete cell
Z Undo cell deletion
Y Change to code cell
M Change to markdown cell
R Change to raw cell
1–6 Change to markdown heading level 1–6
↑ / K Select cell above
↓ / J Select cell below
Shift+↑ Extend selection above
Shift+↓ Extend selection below
Shift+M Merge selected cells
L Toggle line numbers
O Toggle output
Shift+O Toggle output scrolling
I I Interrupt the kernel
0 0 Restart the kernel
S Save notebook
H Show keyboard shortcuts

Edit Mode (Press Enter in cell)

Table A.15: Jupyter edit mode shortcuts
Shortcut Action
Esc Enter command mode
Ctrl+Enter Run cell
Shift+Enter Run cell, select below
Alt+Enter Run cell, insert below
Ctrl+Shift+- Split cell at cursor
Ctrl+S Save notebook
Tab Autocomplete or indent
Shift+Tab Tooltip/docstring
Ctrl+] / Ctrl+[ Indent / dedent
Ctrl+/ Comment/uncomment
Ctrl+Z / Ctrl+Shift+Z Undo / redo within the cell

The same command-mode and edit-mode shortcuts work in JupyterLab (including the JupyterLab served by Open OnDemand on Talapas, Section 20.4.3) and, with Ctrl replaced by Cmd on macOS, in notebooks opened inside VS Code or Positron.

A.6 VS Code Shortcuts

General

Table A.16: VS Code general shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Cmd+Shift+P Ctrl+Shift+P Command palette
Cmd+P Ctrl+P Quick file open
Cmd+, Ctrl+, Open settings
Cmd+K Cmd+S Ctrl+K Ctrl+S Keyboard shortcuts
Ctrl+` Ctrl+` Toggle terminal
Cmd+B Ctrl+B Toggle sidebar
Cmd+Shift+E Ctrl+Shift+E Focus the Explorer (file tree)
Cmd+Shift+F Ctrl+Shift+F Search across the whole project
Ctrl+Shift+G Ctrl+Shift+G Source Control (Git) panel
Cmd+Shift+X Ctrl+Shift+X Extensions panel
Cmd+\ Ctrl+\ Split the editor
Cmd+W Ctrl+W Close the current editor tab
Cmd+Shift+N Ctrl+Shift+N New window
Cmd+Shift+V Ctrl+Shift+V Markdown preview
Cmd+Shift+K Ctrl+Shift+K Render/preview the Quarto document (Quarto extension, in .qmd files; in other files it deletes the line)
TipWhere is the backtick?

The backtick (`) that toggles the terminal is on the key above Tab (shared with ~), not the apostrophe key. Note also that VS Code uses Ctrl, not Cmd, for this shortcut even on macOS.

Editing

Table A.17: VS Code editing shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Cmd+X Ctrl+X Cut line (no selection)
Cmd+C Ctrl+C Copy line (no selection)
Alt+↑/↓ Alt+↑/↓ Move line up/down
Shift+Alt+↑/↓ Shift+Alt+↑/↓ Copy line up/down
Cmd+Shift+K Ctrl+Shift+K Delete line
Cmd+Enter Ctrl+Enter Insert line below (in Positron: send line to console)
Cmd+Shift+Enter Ctrl+Shift+Enter Insert line above
Cmd+] / Cmd+[ Ctrl+] / Ctrl+[ Indent / outdent line
Cmd+/ Ctrl+/ Toggle comment
Shift+Alt+A Shift+Alt+A Toggle block comment
Cmd+D Ctrl+D Select next occurrence
Cmd+Shift+L Ctrl+Shift+L Select all occurrences
Cmd+L Ctrl+L Select current line
Cmd+Shift+\ Ctrl+Shift+\ Jump to matching bracket
Cmd+F Ctrl+F Find
Cmd+Alt+F Ctrl+H Find and replace
Cmd+Shift+F Ctrl+Shift+F Find in files

Navigation

Table A.18: VS Code navigation shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Ctrl+G Ctrl+G Go to line
Cmd+Shift+O Ctrl+Shift+O Go to symbol
F12 F12 Go to definition
Alt+F12 Alt+F12 Peek definition
Ctrl+- Alt+← Go back
Ctrl+Shift+- Alt+→ Go forward
Cmd+U Ctrl+U Undo the last cursor movement
Ctrl+Tab Ctrl+Tab Switch between open editors
Cmd+K Cmd+Q Ctrl+K Ctrl+Q Go to last edit location
Cmd+Home / Cmd+End Ctrl+Home / Ctrl+End Beginning / end of file

Multiple Cursors and Selection

Table A.19: VS Code multi-cursor shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Alt+Click Alt+Click Insert an additional cursor
Cmd+Alt+↑/↓ Ctrl+Alt+↑/↓ Insert cursor above/below
Cmd+D Ctrl+D Add the next occurrence of the selection to the selection
Cmd+F2 Ctrl+F2 Select all occurrences of the current word
Shift+Alt+I Shift+Alt+I Insert a cursor at the end of each selected line
Shift+Alt+Drag Shift+Alt+Drag Column (box) selection
Cmd+U Ctrl+U Undo the last cursor operation

Integrated Terminal

Table A.20: VS Code terminal shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Ctrl+` Ctrl+` Toggle the terminal panel
Ctrl+Shift+` Ctrl+Shift+` Open a new terminal
Cmd+\ Ctrl+Shift+5 Split the terminal
Cmd+↑/↓ Ctrl+↑/↓ Scroll terminal by line
Shift+PageUp/PageDown Shift+PageUp/PageDown Scroll terminal by page

Inside the terminal panel the shell’s own shortcuts (Section A.1) apply, so Ctrl+C, Ctrl+R, and Ctrl+A/Ctrl+E behave as they would in a standalone terminal.

A.7 Positron Shortcuts

Positron (Section 2.5) is built on the same core as VS Code, so every shortcut in Section A.6 works unchanged. What it adds are data-science bindings, listed in Table A.21.

Table A.21: Positron data-science shortcuts (all VS Code shortcuts also apply)
Shortcut (Mac) Shortcut (Windows/Linux) Action
Cmd+Enter Ctrl+Enter Send the current line or selection to the R/Python console
Cmd+Shift+Enter Ctrl+Shift+Enter Run the current code chunk (Quarto)
Cmd+Shift+M Ctrl+Shift+M Insert pipe \|>
Alt+- Alt+- Insert assignment <-
Cmd+Shift+K Ctrl+Shift+K Render/preview the Quarto document
Cmd+Shift+V Ctrl+Shift+V Markdown preview
Cmd+Shift+0 Ctrl+Shift+0 Restart the active interpreter (R or Python)
F1 F1 Help for the function under the cursor

A.8 RStudio Shortcuts

RStudio (Section 2.6) shares its core code-execution and Quarto bindings with Positron, so Table A.21 largely applies. The table below lists the ones specific to RStudio’s four-pane layout.

Table A.22: RStudio shortcuts
Shortcut (Mac) Shortcut (Windows/Linux) Action
Cmd+Enter Ctrl+Enter Run the current line or selection in the Console
Cmd+Shift+S Ctrl+Shift+S Source (run) the whole script
Cmd+Shift+Enter Ctrl+Shift+Enter Run the current Quarto chunk
Cmd+Option+I Ctrl+Alt+I Insert a new code chunk
Cmd+Shift+K Ctrl+Shift+K Render the Quarto document
Cmd+Shift+M Ctrl+Shift+M Insert pipe \|>
Option+- Alt+- Insert assignment <-
Cmd+Shift+C Ctrl+Shift+C Comment / uncomment the selection
Cmd+Shift+F10 Ctrl+Shift+F10 Restart the R session
Ctrl+1 / Ctrl+2 Ctrl+1 / Ctrl+2 Move focus to Source / Console
Cmd+Shift+F Ctrl+Shift+F Find in files
Cmd+Shift+P Ctrl+Shift+P Command palette (search every RStudio command)
F1 F1 Help for the function under the cursor

A.9 Platform Differences

The tables above list macOS and Windows/Linux forms side by side where they differ. The general rule (Table A.23) is that the Ctrl of Windows and Linux becomes Cmd (⌘) on a Mac and Alt becomes Option (⌥), except in the terminal, in Vim, and in a few editor bindings that were inherited from the terminal (VS Code’s Ctrl+` and Ctrl+G, RStudio’s Ctrl+1–Ctrl+9 pane shortcuts), which keep Ctrl on every platform because the shell itself interprets those keys.

Table A.23: Modifier keys across platforms
Windows/Linux macOS Applies to
Ctrl Cmd (⌘) Editors and IDEs (VS Code, Positron, RStudio, Jupyter)
Alt Option (⌥) Editors and IDEs
Ctrl+Alt Cmd+Option Editors and IDEs
Ctrl Ctrl Bash, Vim, tmux/screen, and the integrated terminal

On a Mac, Alt+B/Alt+F and the other Alt shortcuts in Section A.1 require the terminal to treat Option as Meta (Terminal: Settings → Profiles → Keyboard → Use Option as Meta Key; iTerm2: Profiles → Keys → Option key: Esc+). Without that setting, Option+F types “ƒ” instead of moving a word.

TipCustomizing shortcuts

Every tool here lets you change its bindings, and it is worth doing for the few commands you use constantly:

  • RStudio: Tools → Modify Keyboard Shortcuts…
  • VS Code and Positron: File → Preferences → Keyboard Shortcuts (Cmd+K Cmd+S / Ctrl+K Ctrl+S); bindings are stored in keybindings.json, which you can keep in Git
  • Jupyter: Settings → Settings Editor → Keyboard Shortcuts (JupyterLab) or Help → Edit Keyboard Shortcuts (classic Notebook)
  • Bash: readline bindings in ~/.inputrc

Learn the defaults first, though: they are what you will find on a collaborator’s laptop, on Talapas, and in every tutorial.