MacOS VS Code Shortcuts for Easy Terminal Navigation

The Visual Studio Code Integrated Terminal is a handy, full-featured terminal emulator available right in VS Code. My typical workflow for projects often involves using VS Code and the integrated terminal in tandem.

Below is a curated list of shortcuts I am either using (or would like to remember to use!) with the VS Code Integrated Terminal on macOS. A complete list of shortcuts is available in VS Code: open the keyboard shortcuts page (Command ⌘ + Shift + P > Preferences: Open Keyboard Shortcuts) and search for "Terminal" to view or change relevant shortcuts.

Opening the Terminal

VS Code editor with an integrated terminal opened in the bottom panel

ShortcutComment
Ctrl + `Open / hide terminal panel

Terminal Groups

VS Code editor with two integrated terminals (split terminals) opened in the bottom panel

ShortcutComment
Command ⌘ + \Create a new split terminal
Ctrl+ Shift + `Create a new terminal
Command ⌘ + Shift + ]Focus next terminal group
Command ⌘ + Shift + [Focus previous terminal group
Command ⌘ + Shift + Focus next split terminal in group
Command ⌘ + Shift + Focus previous split terminal in group

For macOS, to use many of the shortcuts to move around the terminal, we need to treat the Option ( / alt) key as the meta key within VS Code. In your JSON settings for VS Code (Command ⌘ + Shift + P > Open User Settings (JSON)) add the following line:

json
"terminal.integrated.macOptionIsMeta": true

The Emacs shortcuts, below, work in both Zsh (which, by default, uses Emacs-bindings with zle) and Bash (which uses readline commands).

Moving

ShortcutDescription
Ctrl+aBeginning of line
Ctrl+eEnd of line
Ctrl+b / Backward character
Ctrl+f / Forward character
Meta+fForward word
Meta+bBackward word

History

HistoryDescription
Ctrl+rReverse history search

Changing Text

ShortcutDescription
Ctrl+lClear screen
Ctrl+gCancel
Ctrl+_Undo

Copy & Paste

ShortcutDescription
Meta+dCut word after cursor
Ctrl+wCut word before cursor
Ctrl+dCut one character
Ctrl+kCut everything before cursor
Ctrl+yPaste

Vim

Vim + Zsh users may prefer using vi-mode instead of learning the above shortcuts, while Vim + Bash users can similarly set their mode to Vim.