02-Terminal Basics
02-Terminal Basics
com/docs/terminal/basics
(https://vscode.dev/github/microsoft/vscode-docs/blob/main/docs/terminal/basics.md)
Terminal Basics
Visual Studio Code includes a full featured integrated terminal that starts at the root of your workspace. It
provides integration with the editor to support features like links and error detection (/docs/editor/tasks).
The integrated terminal can run commands such as mkdir and git just like a standalone terminal.
• From the menu, use the Terminal > New Terminal or View > Terminal menu commands.
• From the Command Palette ( ⇧⌘P ), use the View: Toggle Terminal command.
• In the Explorer, you can use the Open in Integrated Terminal context menu command to open a new
terminal from a folder.
• To toggle the terminal panel, use the ⌃` keyboard shortcut.
• To create a new terminal, use the ⌃⇧` keyboard shortcut.
VS Code's terminal has additional functionality called shell integration that tracks where commands are
run with decorations on the left of a command and in the scrollbar:
Note: If you prefer to work outside VS Code, open an external terminal with the ⇧⌘C keyboard
shortcut
Terminal shells
The integrated terminal can use various shells installed on your machine, with the default being pulled
from your system defaults. Shells are detected and presented in the terminal profiles dropdown.
You can learn more about configuring terminal shells in the terminal profiles (/docs/terminal/profiles)
article.
Managing terminals
The terminal tabs UI is on the right side of the terminal view. Each terminal has an entry with its name,
icon, color, and group decoration (if any).
Add terminal instances by selecting the + icon on the top-right of the TERMINAL panel, selecting a profile
from the terminal dropdown, or by triggering the ⌃⇧` command. This action creates another entry in the
tab list associated with that terminal.
Remove terminal instances by hovering a tab and selecting the Trash Can button, selecting a tab item and
pressing Delete , using Terminal: Kill the Active Terminal Instance command, or via the right-click
context menu.
Navigate between terminal groups using focus next ⇧⌘] and focus previous ⇧⌘[ .
Icons may appear to the right of the terminal title on the tab label when a terminal's status changes. Some
examples are a bell (macOS) and for tasks, displaying a check mark when there are no errors and an X
otherwise. Hover the icon to read status information, which may contain actions.
• Hover over a entry in the list of terminals on the right and select the inline split button.
• Right-click the context menu and selecting the Split menu option.
• Alt and click on a tab, the + button, or the single tab on the terminal panel.
• Trigger the ⌘\ command.
Tip: The working directory for the new terminal depends on the
! (vscode://settings/terminal.integrated.splitCwd)terminal.integrated.splitCwd setting (/docs/
editor/settings).
Navigate between terminals in a group by focusing the previous pane, ⌥⌘← , or the next pane, ⌥⌘→ .
Dragging and dropping tabs in the list rearranges them. Dragging a tab into the main terminal area allows
moving a terminal from one group to another.
Moving a terminal into its own group can be done with the Terminal: Unsplit Terminal command through
the Command Palette or in the right-click context menu.
You can open terminals in the editor area (terminal editors) with the Terminal: Create New Terminal in
Editor Area command, the Terminal: Create New Terminal in Editor Area to the Side command, or by
dragging a terminal from the terminal view into the editor area. Terminal editors are presented like regular
editor tabs:
You can have terminal editors on either side or arranged in multiple dimensions using the editor group
layout system, e.g. PowerShell and WSL terminals stacked to the right of file editors:
The ! (vscode://settings/terminal.integrated.defaultLocation)terminal.integrated.defaultLocation
setting can change the default view or editor area terminal location.
The content in the terminal is called the buffer, with the section right above the bottom viewport being
called "scrollback". The amount of scrollback kept is determined by the
! (vscode://settings/terminal.integrated.scrollback)terminal.integrated.scrollback setting (/docs/editor/
settings) and defaults to 1000 lines.
There are various commands available to navigate around the terminal buffer:
Scrolling will happen instantaneously, but can be configured to animate over a short duration with the
! (vscode://settings/terminal.integrated.smoothScrolling)terminal.integrated.smoothScrolling setting.
Links
The terminal features sophisticated link detection with editor integration and even extension contributed
link handlers. Hover over a link to display an underline, then hold the Ctrl / Cmd key and click.
These built-in link handlers are used in the following priority order:
• File links: Links to files that have been verified to exist on the system. These will open the file in a
new editor tab and support many common line/column formats such as file:1:2 , file:line 1,
column 2 .
• Folder links: Links to folders are similar to file links but will open a new VS Code window at the
folder.
The Open Detected Link command ( ⇧⌘G ) can be used to access links via the keyboard:
Tip: If link verification causes performance issues, like in high latency remote environments, disable it
via the
! (vscode://settings/terminal.integrated.enableFileLinks)terminal.integrated.enableFileLinks
setting (/docs/editor/settings).
Keyboard accessibility
Links are keyboard accessible through several commands that open links based on the type of link.
• Terminal: Open Last Local File Link - Opens the most recent local file link. No default keyboard
shortcut.
• Terminal: Open Last URL link - Opens the most recent URI/URL link. No default keyboard shortcut.
• Terminal: Open Detected Link... - Opens a searchable Quick Pick with all detected links, including
word links. The default keyboard shortcut is Ctrl/Cmd+Shift+O , which is the same as the Go to
Symbol in Editor keyboard shortcut.
The keyboard shortcuts for copy and paste follow platform standards:
By default, there is a warning when pasting multiple lines, which can be disabled with the
! (vscode://settings/
terminal.integrated.enableMultiLinePasteWarning)terminal.integrated.enableMultiLinePasteWarning
setting. This is only done when the shell does not support "bracketed paste mode". When that mode is
enabled, the shell is indicating that it can handle multiple line pasting.
Right-click behavior
The right-click behavior differs based on the platform:
• macOS: Select the word under the cursor and show the context menu.
• Windows: Copy and drop selection if there is a selection, otherwise paste.
Find
The integrated terminal has find functionality that can be triggered with ⌘F .
To use the runSelectedText command, select text in an editor and run the command Terminal: Run
Selected Text in Active Terminal via the Command Palette ( ⇧⌘P ), the terminal will attempt to run the
selected text. If no text is selected in the active editor, the entire line that the cursor is on will run in the
terminal.
Tip: Also run the active file using the command workbench.action.terminal.runActiveFile .
The terminal view can be maximized by clicking the maximize panel size button with the upwards chevron
icon. This will temporarily hide the editors and maximize the panel. This is useful to temporarily focus on a
large amount of output. Some developers use VS Code as a standalone terminal by opening a new window,
maximizing the panel, and hiding the side bar.
Note that the panel can only be maximized if its alignment (/docs/editor/custom-layout#_panel-alignment)
option is set to Center.
Select all
There is a Terminal: Select All command, which is bound to Cmd+A on macOS, but does not have a
default keyboard shortcut on Windows and Linux as it may conflict with shell hotkeys. To use Ctrl+A to
select all, add this custom keyboard shortcut:
{ Copy
"key": "ctrl+a",
"command": "workbench.action.terminal.selectAll",
"when": "terminalFocus && !isMac"
},
Dragging a file into the terminal will input the path into the terminal, with escaping to match the active
shell.
The Tasks (/docs/editor/tasks) feature can be used to automate the launching of terminals, for example,
the following .vscode/tasks.json file will launch a Command Prompt and PowerShell terminal in a single
terminal group when the window starts:
{ Copy
"version": "2.0.0",
"presentation": {
"echo": false,
"reveal": "always",
"focus": false,
"panel": "dedicated",
"showReuseMessage": true
},
"tasks": [
{
"label": "Create terminals",
"dependsOn": [
"First",
"Second"
],
// Mark as the default build task so cmd/ctrl+shift+b will create them
"group": {
"kind": "build",
"isDefault": true
},
// Try start the task on folder open
"runOptions": {
"runOn": "folderOpen"
}
},
{
// The name that shows up in terminal tab
"label": "First",
// The task will launch a shell
"type": "shell",
"command": "",
// Set the shell type
"options": {
"shell": {
"executable": "cmd.exe",
"args": []
}
},
// Mark as a background task to avoid the spinner animation on the terminal ta
b
"isBackground": true,
"problemMatcher": [],
// Create the tasks in a terminal group
"presentation": {
"group": "my-group"
}
},
{
"label": "Second",
"type": "shell",
"command": "",
"options": {
"shell": {
"executable": "pwsh.exe",
"args": []
}
},
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "my-group"
}
}
]
}
This file could be committed to the repository to share with other developers or created as a user task via
the workbench.action.tasks.openUserTasks command.
Working directory
By default, the terminal will open at the folder that is opened in the Explorer. The
! (vscode://settings/terminal.integrated.cwd)terminal.integrated.cwd setting allows specifying a custom
path to open instead:
{ Copy
"terminal.integrated.cwd": "/home/user"
}
Split terminals on Windows will start in the directory that the parent terminal started with. On macOS and
Linux, split terminals will inherit the current working directory of the parent terminal. This behavior can be
changed using the ! (vscode://settings/terminal.integrated.splitCwd)terminal.integrated.splitCwd
setting:
{ Copy
"terminal.integrated.splitCwd": "workspaceRoot"
}
There are also extensions available that give more options such as Terminal Here (https://
marketplace.visualstudio.com/items?itemName=Tyriar.vscode-terminal-here).
The Terminal: Set Fixed Dimensions command allows changing the number of columns and rows that the
terminal and it's backing pseudoterminal uses. This will add scroll bars when necessary, which may lead to
an unpleasant UX and is generally not recommended, but it is a common ask on Windows in particular for
reading logs or long lines when paging tools aren't available.
You can also right-click on a terminal tab and select Toggle Size to Content Width ( ⌥Z ) to resize the
number of terminal columns to the largest wrapped line in the terminal.
Next steps
The basics of the terminal have been covered in this document. Read on to find out more about:
Common questions
You can learn more about customizing terminals via terminal profiles in Configuring Profiles (/docs/
terminal/profiles#_configuring-profiles).
Can I add a keyboard shortcut for the Explorer's Open in Integrated Terminal command?
You can open new terminals for specific folders from the Explorer via the Open in Integrated Terminal
context menu command.
By default, there is no keyboard shortcut associated with Open in Integrated Terminal but you can add
your own via the Keyboard Shortcuts editor ( ⌘K ⌘S ) to add a keyboard shortcut to your
keybindings.json .
The keybindings.json example below adds the keyboard shortcut Ctrl+T for openInTerminal .
{ Copy
"key": "ctrl+t",
"command": "openInTerminal",
"when": "filesExplorerFocus"
}
Why is nvm complaining about a prefix option when the integrated terminal is launched?
nvm (Node Version Manager) users often see this error for the first time inside VS Code's integrated
terminal:
Copy
nvm is not compatible with the npm config "prefix" option: currently set to "/usr/lo
cal"
Run `npm config delete prefix` or `nvm use --delete-prefix v8.9.1 --silent` to unset
it
This is mostly a macOS problem and does not happen in external terminals. The typical reasons for this
• npm was globally installed using another instance of node that is somewhere in your path (such as
/usr/local/bin/npm ).
• To get the development tools on the $PATH , VS Code will launch a bash login shell on startup. This
means that your ~/.bash_profile has already run and when an integrated terminal launches, it will
run another login shell, reordering the $PATH potentially in unexpected ways.
To resolve this issue, you need to track down where the old npm is installed and remove both it and its
out-of-date node_modules. Find the nvm initialization script and run which npm before it runs, which
should print the path when you launch a new terminal.
Once you have the path to npm, find the old node_modules by resolving the symlink by running a
command something like this:
From there, removing the files and relaunching VS Code should fix the issue:
Why does macOS make a ding sound when I resize terminal split panes?
The keyboard shortcuts ⌃⌘← and ⌃⌘→ are the defaults for resizing individual split panes in the terminal.
While they work, they also cause a system "invalid key" sound to play due to an issue in Chromium. The
recommended workaround (https://github.com/microsoft/vscode/
issues/44070#issuecomment-799716362) is to tell macOS to no-op for these keyboard shortcuts by
running this in your terminal:
I'm having problems with the terminal rendering. What can I do?
By default, the integrated terminal will render using GPU acceleration on most machines. Typically when
there are rendering problems it's an issue of something in your hardware/OS/drivers not playing nicely with
the GPU renderer. The first thing to try is to disable GPU acceleration, trading off rendering speed for
DOM-based rendering, which is more reliable:
{ Copy
"terminal.integrated.gpuAcceleration": "off"
}
Alternatively, bracketed paste mode can be forced to ignore the shell's request by turning it off with this
setting:
{ Copy
"terminal.integrated.ignoreBracketedPasteMode": true
}
• Ensure that you don't set $EDITOR to vi(m) . However, this isn't an option if you want your Git
editor to work.
• Add bindkey -e to your init script to set Emacs explicitly.
How can I configure Cmd+. to map to Ctrl+C like macOS' built-in terminal?
The macOS default terminal uses Cmd+. to perform the same as Ctrl+C . To get this behavior in VS
{ Copy
"key": "cmd+.",
"command": "workbench.action.terminal.sendSequence",
"when": "terminalFocus",
"args": { "text": "\u0003" }
}
"terminal.integrated.minimumContrastRatio": 1 Copy
Yes No
02/06/2025
Follow @code(https://go.microsoft.com/fwlink/?LinkID=533687)
Request features(https://go.microsoft.com/fwlink/?LinkID=533482)
Report issues(https://www.github.com/Microsoft/vscode/issues)
Watch videos(https://www.youtube.com/channel/UCs5Y5_7XK8HLDX0SLNwkd3w)
(https://
www.microsoft.com)
(https://go.microsoft.com/fwlink/?LinkID=533687)
(https://github.com/microsoft/vscode) (https://www.youtube.com/@code)
Support (https://support.serviceshub.microsoft.com/supportforbusiness/create?sapId=d66407ed-3967-
b000-4cfb-2c318cad363d)
Privacy (https://go.microsoft.com/fwlink/?LinkId=521839)
Terms of Use (https://www.microsoft.com/legal/terms-of-use) License (/License)