# Mastering the Visual Studio Code Integrated Terminal

Published
Tags:

Visual Studio Code’s integrated terminal can be launched with ctrl+. This article goes into some of the lesser known tips and tricks of the terminal.

VS Code will try pick your preferred terminal on Linux and macOS by looking at the \$SHELL environment variable, on Windows Powershell is the default. You can customize which shell using the following settings:

• terminal.integrated.shell.linux
• terminal.integrated.shell.osx
• terminal.integrated.shell.windows

There are also settings that specify the arguments that the shell is launched with. For example you could launch bash on macOS as a login shell with the following:

{
"terminal.integrated.shell.osx": "/bin/bash",
"terminal.integrated.shellArgs.osx": ["-l"]
}


There are some good recommendations on how to configure the various Windows shells on the official documentation page.

## Text style

The text style of the terminal can be set using the following settings:

• terminal.integrated.fontFamily
• terminal.integrated.fontLigatures
• terminal.integrated.fontSize
• terminal.integrated.lineHeight

No customising the colours just yet though.

## Terminal cursor

The terminal cursor can be set to a block (default), line/bar or underline. It can also be made to blink:

{
"terminal.integrated.cursorStyle": "line"
}


## Increasing the buffer size

The terminal keeps 1000 lines of data by default before it starts discarding them, this number can be customized with terminal.integrated.scrollback:

{
"terminal.integated.scrollback": 5000
}


## Maximizing the terminal

The panel can be maximized by adding a keybinding, once it’s maximized triggering the command again will restore the panel to its previous size. This is useful when you need to look at a diff or do some temporary heavy terminal work.

[
{ "key": "ctrl+shift+q", "command": "workbench.action.toggleMaximizedPanel" }
]


## Working with multiple terminals

There are several commands that make managing multiple terminals much easier, they do not have default keybindings but you can easily bind them in your keybindings.json file:

[
{ "key": "ctrl+shift+x", "command": "workbench.action.terminal.kill" },
{ "key": "ctrl+shift+j", "command": "workbench.action.terminal.focusNext" },
{ "key": "ctrl+shift+k", "command": "workbench.action.terminal.focusPrevious" },
]


## Copy and paste

Standards for copying and pasting in terminals vary between platforms:

• Linux:
• Copy: ctrl+shift+c
• Paste: ctrl+shift+v
• macOS:
• Copy: +c
• Paste: +v
• Windows:
• Copy: ctrl+c when there is a selection
• Paste: ctrl+v
• Right clicking on terminal copies when there is a selection and pastes when there is no selection

Luckily most of this was done in a generic way so you can configure it however you want. For example if a Linux user wanted to adopt the Windows settings they could add the following to their keybindings.json file:

[
{ "key": "ctrl+c", "command": "workbench.action.terminal.copySelection",
"when": "terminalFocus && terminalTextSelected" },
{ "key": "ctrl+v", "command": "workbench.action.terminal.paste",
"when": "terminalFocus" }
]


And this to their settings.json:

{
"terminal.integrated.rightClickCopyPaste": true
}


You can even unbind default keybindings if desired by prepending the keybinding command with -:

[
{ "key": "ctrl+shift+c", "command": "-workbench.action.terminal.copySelection",
"when": "terminalFocus && terminalTextSelected" },
{ "key": "ctrl+shift+v", "command": "-workbench.action.terminal.paste",
"when": "terminalFocus" },
]


A nice trick to make switching focus to the terminal from the editor using the keybiding less frustrating is to overriding the ctrl+ keybinding to focus when the terminal is not focused:

{
"key": "ctrl+", "command": "workbench.action.terminal.focus",
"when": "!terminalFocus"
}


## Launch vscode at the terminal’s directory

Like most editors you can launch a new instance of vscode through the command line with:

code .


A little known trick though is that you can the folder in the most recently used vscode window by passing in the -r command line argument:

code -r .


This even works in the integrated terminal!

## Extensions

VS Code features an extension API that enables extensions to launch and communicate with terminals. Here are some useful ones:

## External terminal

VS Code also features a convenient way to launch an external terminal as well via the workbench.action.terminal.openNativeConsole` command (/ctrl+shift+c).