Visual Studio Code comes with a fully integrated terminal that is conveniently launched from the root of your workspace. It offers editor integration to support features such asconnectionseerror detection.
To open the Terminal:
- Use o⌃`(Windows, LinuxCtrl+`)Keyboard shortcut to toggle the terminal panel.
- Use o⌃⇧`(Windows, LinuxCtrl+Shift+`)Keyboard shortcut for creating a new terminal.
- Use oto view>terminalorterminal>new devicemenu commands.
- Docommand paddle(⇧⌘S(Windows, LinuxCtrl+Shift+P)), Use oDisplay: Switch terminalCommand.
Observation:Open an external terminal with the⇧⌘C(Windows, LinuxCtrl+Shift+C)Keyboard shortcuts if you prefer to work outside of VS Code.
terminal shells
The built-in terminal can use various shells installed on your computer, drawing default settings from your system defaults. Shells are recognized and displayed in the terminal profile drop-down list.
For more information on configuring terminal shells, see theTerminalprofileArticle.
Manage End Devices
The terminal tabs UI is located on the right side of the terminal view. Each terminal has an entry with the group's name, icon, color and decoration (if any).
Endpoint instances can be added by selecting+icon in the upper right corner of theTERMINALControl Panel, selecting a profile from the Terminal drop-down list, or launching the⌃⇧`(Windows, LinuxCtrl+Shift+`)Command. This action creates another entry in the list of tabs associated with this endpoint.
Remove terminal instances by hovering over a tab and selecting itTrash canbutton, select a tab item and pressextinguish, useTerminal: Exit the running terminal instancecommand or via the right-click context menu.
Navigate between endpoint groups by continuing to use focus⇧⌘](Windows, LinuxCtrl+Page Down)and previous focus⇧⌘[(Windows, LinuxCtrl+Page Up).
When an endpoint's status changes, icons may appear to the right of the endpoint's title in the tab's label. Some examples are a bell (macOS) and for tasks that show a checkmark if there are no errors and an X. Mouse over the icon to read status information, which may include actions.
Groups (split windows)
Several terminals can be placed next to each other, they are called a group and are created by splitting a terminal:
- On hover, select the split line button.
- Right-click the context menu and select thedivisionsMenu option.
- Altand click on a tab that+button or the individual tab on the connector panel.
- activating the⌘\(Windows, LinuxCtrl+Shift+5)Command.
Principal:The working directory for the new terminal depends on the
terminal.integrated.splitCwd
Attitude.
Navigate between terminals in a group by focusing on the previous window,⌥⌘←(Windows, LinuxAlt+Links), or the next window,⌥⌘→(Windows, LinuxAlt+Right).
Dragging and dropping tabs in the list rearranges them. Dragging a tab into the main terminal area lets you move a terminal from one group to another.
Moving a terminal to its own group can be done withTerminal: undivided terminalCommand via the command palette or the right-click context menu.
Staples in the editor area
Terminal in the editor area, also known as terminal editors, can be created through theTerminal: Create a new terminal in the editor areaeTerminal: Create a new terminal in the side editor panelcommands or by dragging a terminal from the terminal view into the editor area.
Terminal editors are ideal when you want a complex workbench layout, for example B. Terminals on either side of an editor, or terminals arranged in two dimensions. Below are PowerShell and WSL endpoints stacked in an editor group to the right of a file editor group.
Dieterminal.integrated.defaultLocation
The configuration can change the default location of the terminal to be in theOpinion
oreditor
areas.
browse the buffer
The content in the terminal is called the buffer, with the section just above the bottom viewport called "scrollback". The amount of roll retained is determined byterminal.integrated.scrollback
Attitudeand enabled by default1000
lines.
Several commands are available to browse the terminal buffer:
- Scroll up one line -⌥⌘image above(WindowCtrl+Alt+Page Up, LinuxCtrl+Shift+Cima)
- Scroll down one line -⌥⌘Page Down(WindowCtrl+Alt+Page Down, LinuxCtrl+Shift+Down)
- Scroll up one page -upload page(Windows, LinuxShift + Page Up)
- Scroll down one page -image down(Windows, LinuxShift+Page Down)
- Scroll up -⌘Zuhause(WindowCtrl+Home, LinuxShift+Home)
- Roll down -⌘Ende(WindowCtrl+Fim, LinuxShift+Fim)
commandNavigation is also available (seeShell-Integration):
- Scroll to previous command -⌘↑(Windows, LinuxCtrl+Up)
- Scroll to next command -⌘↓(Windows, LinuxCtrl+Down)
Scrolling is instantaneous, but can be set to animate for a short timeterminal.integrated.smoothscrolling
Attitude.
connections
The endpoint has sophisticated link detection with editor integration and even link handlers contributed by extensions. Links are activated by hovering over the link so that an underline appears, then holding downctrl/beforeand click.
There are several built-in link handlers that are used in the following order of precedence:
URIs/URLs: These are links that look like URIs, like
https://code.visualstudio.com
. They open the system browser at this point.(Video) Visual Studio Code Terminals ConfigurationFile links: These are links that we verify represent files on the system. They open the file in a new editor tab and support common row/column formats such as
File:1:2
,File: line 1, column 2
.Folder links: These are similar to file links, but open a new VS Code window on the folder.
Word Links: This is the fallback link type and uses the
terminal.integrated.wordSeparators
Setting to set word limits and convert almost all text to words. Enabling a word link will search the workspace for the word; if there is a single result, it will be opened; otherwise, search results will be displayed. Word links are considered "low confidence" and will not show an underline or tooltip unlessctrl/beforeis held. They also have limited support for row and column suffixes.
Extensions that handle links
Extensions can helplink providerthat allow the extension to define what happens when clicked. An example of this is theGitLensGenericNameextension recognizes git branch links.
keyboard accessibility
Links can be accessed through various keyboard commands that open links based on the type of link. These commands do not have default keyboard shortcuts.
- Terminal: Open last local file link- Opens the latest local file link.
- Terminal: Open last URL link- Opens the latest URI/URL link.
- Terminal: Open link found...- Opens a searchable quick selector with all links (including word links).
copy paste
Keyboard shortcuts for copying and pasting follow platform standards:
- Linux:Ctrl+Shift+CeCtrl+Shift+V; Collage selection is available withShift+Insert
- MacOS:Cmd+CeCommand+V
- Window:Strg+CeCtrl+V
Copying occurs automatically when you select whetherterminal.integrated.copyOnSelection
activated.
By default when inserting multiple lines there is a warning which can be disabled withterminal.integrated.enableMultiLinePasteWarning
Attitude. This only happens if the shell doesn't support "parenthesis insertion mode". When this mode is on, the shell indicates that it can handle entering multiple lines.
with the mouse
Right click behavior
Right click behavior differs by platform:
- Linux: Show context menu.
- macOS: Select the word under the cursor and display the context menu.
- Windows: Copy and drop selection if there is a selection, paste otherwise.
This can be configured withterminal.integrated.rightClickBehavior
Attitude. The options are:
Originally
- Show context menu.copy paste
- Copy if there is a selection, paste otherwise.Insert
- Paste on right click.selectWort
- Select the word under the cursor and display the context menu.nothing
- Do nothing and pass the event to the terminal.
Reposition the cursor with Alt
Altand left-clicking positions the cursor under the mouse. This works by simulating arrow keys, which may not work reliably in some shells or programs. This function can be deactivated withterminal.integrated.altClickMovesCursor
Attitude.
mouse event mode
When applications running in the terminal activate mouse event mode, eg For example Vim mouse mode sends the mouse interaction to the application instead of the terminal. This means that clicking and dragging will no longer create a selection. Terminal selection can be forced by pressingAltkey on Windows and Linux, this can also be done with thepossibilitykey on macOS, but requires activation ofterminal.integrated.macOptionClickForcesSelection
setup first.
To think
The integrated terminal has a search function that can be triggered with⌘F(Windows, LinuxCtrl+F).
Principal: Ctrl+Fcan be sent to the shell by removing the
workbench.action.terminal.focusFind
command ofshell skip commands.
Run selected text
to use therunSelectedText
command, select the text in an editor and run the commandTerminal: Runs the selected text in the active terminalregarding thecommand paddle(⇧⌘S(Windows, LinuxCtrl+Shift+P)), the terminal tries to execute the selected text. If no text is selected in the active editor, the entire line the cursor is on is executed in the terminal.
Principal:Also run the active file with the command
workbench.action.terminal.runActiveFile
.
Maximize the terminal
The terminal display can be maximized by clicking the "Maximize panel size" button with the chevron icon pointing upwards. This temporarily hides the editors and maximizes the panel. This is useful for temporarily focusing 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 sidebar.
choose all
There is oneTerminal: select allcommand that is boundCommand+Aon macOS, but lacks a standard key mapping on Windows and Linux because it can conflict with shell shortcut keys. UseStrg+ATo select all, add this custom keyboard shortcut:
{ "Key":"Strg+a", "Command":"workbench.action.terminal.selectAll", "When":"terminalFocus && !isMac"},
Drag and drop file paths
When you drag a file into the terminal, the path is typed into the terminal, using escape characters to match the active shell.
Automate endpoints with tasks
DietasksThe function can be used to automate launching the terminal, for example the following.vscode/tasks.json
The file launches a command prompt and a PowerShell terminal in a single terminal group when the window is launched:
{ "Execution":"2.0.0", "Presentation": { "Eco":INCORRECT, "discover":"always", "Focus":INCORRECT, "Panel":"dedicated", "showReuseMessage":Is correct}, "Tasks": [{ "Label":"Create terminals", "depends on": [ "First", "Second"], // Mark as default build task so cmd/ctrl+shift+b will build it "Group": { "liquid":"build", "istStandard":Is correct}, // Try to start the task when opening the folder "execute options": { "run":"Open Folder"}},{ // The name that will be displayed in the terminal tab "Label":"First", // The task starts a shell "Art":"manga", "Command":"", // Set the shell type "options": { "manga": { "executable":"cmd.exe", "Arguments": []}}, // Mark as background task to avoid spinning animation in terminal tab "isbackground":Is correct, "problem correspondent": [], // Create tasks in a group of terminals "Presentation": { "Group":"my group"}},{ "Label":"Second", "Art":"manga", "Command":"", "options": { "manga": { "executable":"pwsh.exe", "Arguments": []}}, "isbackground":Is correct, "problem correspondent": [], "Presentation": { "Group":"my group"}}]}
This file can be uploaded to the repository to be shared with other developers or created as a user task through theworkbench.action.tasks.openUserTasks
Command.
working directory
By default, the terminal opens in the folder that is open in Explorer. Theterminal.embedded.cwd
The configuration allows specifying a custom path to open:
{ "terminal.integrated.cwd":"/homewender"}
Split terminals on Windows start in the directory where the parent terminal was started. On macOS and Linux, shared terminals inherit the parent terminal's current working directory. This behavior can be changed withterminal.integrated.splitCwd
Attitude:
{ "terminal.integrated.splitCwd":"WorkspaceRoot"}
Extensions are also available that offer more options, such asterminal here.
Fixed dimension clamps
DieTerminal: set fixed dimensionsThe command allows changing the number of columns and rows using the terminal and its supporting pseudo-terminal. This adds scrollbars when needed, which can make for clunky UX and is generally not recommended, but is a common question on Windows, especially for reading logs or long queues when paging tools are not available.
You can also right-click on a terminal tab and selectToggle size to content width(⌥Z(Windows, LinuxAlt+Z)) to change the number of terminal columns to the largest broken line in the terminal.
Next steps
Terminal fundamentals are covered in this document. Read on to learn more about:
- tasks- Tasks allow integration with external tools and intense use of the terminal.
- Mastering the VS Code Terminal- An external blog with many tips for advanced terminal users.
- Explore terminal commands by navigating keyboard shortcuts in VS Code (Settings: opens keyboard shortcutsthen search for 'terminal').
common questions
I'm having trouble starting the terminal
There is onededicated troubleshooting guidefor such problems.
Why is nvm complaining about a prefix option when launching the integrated terminal?
nvm (Node Version Manager) users often first see this error in VS Code's built-in terminal:
nvm is not compatible with npm configuration"Prefix"Option: currentlyTo adjustfor"/usr/local"to run`npm config delete prefix`or`nvm use --delete-prefix v8.9.1 --silent`fordisarmes
This is primarily a macOS issue and does not occur on external terminals. Typical reasons for this are as follows:
npm
was installed globally with another instance ofit
that is somewhere in your path (like/usr/local/bin/npm
).- To use the development tools in
$PATH
, VS Code launches a bash login shell on startup. That means your~/.bash_profile
was already running, and when an integrated terminal is started it will runOtherLogin shell, rearranging the$PATH
possibly in unexpected ways.
To fix this problem, you need to find out where the oldnpm
is installed and remove it and its deprecated node_modules. Find itnvm
Initialization and execution scriptwhich npm
before running, which should print the path when you start a new terminal.
Once you have the path to npm, find the old node_modules by resolving the symbolic link by running a command like this:
ls -la /usr/local/bin | grep"np[mx]"
This will give you the resolved path at the end:
... npm -> ../lib/node_modules/npm/bin/npm-cli.js... npx -> ../lib/node_modules/npm/bin/npx-cli.js
From there, removing the files and restarting VS Code should resolve the issue:
rm /usr/local/bin/npm /usr/local/lib/node_modules/npm/bin/npm-cli.jsrm /usr/local/bin/npx /usr/local/lib/node_modules/npm/bin/npx-cli.js
Why does macOS make a noise when I resize split terminal panes?
Keyboard shortcuts ⌃⌘← and ⌃⌘→ are the default settings for resizing individual split windows in the terminal. While they work, they also cause an "Invalid Key" system sound to play due to a Chromium issue. Therecommended workaroundis to tell macOS not to perform any operations for these key combinations by running this in your terminal:
mkdir -p ~/Biblioteca/KeyBindingscat > ~/Library/KeyBindings/DefaultKeyBinding.dict<<EOF{"^@\UF701" = "noop";"^@\UF702" = "noop";"^@\UF703" = "noop";}EOF
I'm having problems with terminal rendering. What can I do?
By default, the integrated terminal renders with GPU acceleration on most computers. When there are rendering issues, it's usually because something in your hardware/OS/drivers isn't working well with the GPU renderer. The first thing to try is disabling GPU acceleration and switching rendering speed to more reliable DOM-based rendering:
{ "terminal.integrated.gpuAcceleration":"the end"}
see theGPU accelerationsection for more information.
I understand1~
or[201~
when i paste something
This usually means that the program/shell running in the terminal has asked to enable "bracket insertion mode", but something doesn't support it properly. To get around this, you can runprintf "\e[?2004l"
to disable it for this session or add the following to your~/.inputrc
Archive:
suspend activate-bracket-paste
Ctrl+A, Ctrl+R imprime ^A, ^R em zsh
This can happen due to configuration when zsh is in vim mode instead of emacs mode$EDITOR
or$VISIBLE
forvi
/vim
in your startup scripts.
To get around this, you have two options:
- Make sure you don't commit
$EDITOR
forvi(m)
. However, this is not an option if you want your git editor to work. - Add to
binding key -e
to your startup script to explicitly configure Emacs.
How can I configure cmd+. to Ctrl+C as macOS built-in terminal?
macOS default terminal is usedcommand+.do the same asStrg+C. To get this behavior in VS Code add the followingcustom key mapping:
{ "Key":"cmd+.", "Command":"workbench.action.terminal.sendSequence", "When":"Terminal Focus", "Arguments": {"Text":"\u0003"}}
Why are the colors in the terminal wrong?
One of our accessibility features, which we turn on by default, is ensuring that foreground text maintains a minimum contrast ratio of at least 4.5. This feature ensures that the text is readable regardless of the shell and theme used, which is otherwise not possible. To disable this feature, you can set the following:
"terminal.integrated.minimumContrastRatio":1
see theMinimal Contrast Systemsection for more information.
12/07/2022
FAQs
Why is my terminal not showing up in Visual Studio code? ›
If your terminal is set to run as administrator only, and you are not launching VS Code as administrator, the terminal will not be able to open. You can either change the default terminal or edit the properties of the terminal exe to not run as administrator.
Does Visual Studio have an integrated terminal? ›You can open an integrated terminal window in Visual Studio for Mac, starting at the root of your solution.
What is the default integrated terminal in VS Code? ›The default terminal profile shell defaults to $SHELL on Linux and macOS and PowerShell on Windows. VS Code will automatically detect most standard shells that can then be configured as the default.
How to install npm in Visual Studio Code? ›- Click Ctrl+P.
- Write ext install npm script runner.
- On the results list look for npm 'npm commands for VS Code'. This npm manages commands. Click Install, then Reload VS Code to save changes.
- Restart VS Code.
- On the Integrated Terminal, Run 'npm install'
Second way
Another way to select a default terminal is to open up a new terminal in VS Code. Next to the big plus sign, click on the dropdown and select “Select Default Profile“. From the dropdown select “Git Bash” and you're all set. Reopen a new terminal to make sure Git Bash opens up as default.
- A faster way to launch the terminal is to use the default keyboard shortcut Ctrl +`.
- We can use the context menu from the Solution Explorer to open the terminal at a specific file path.
“Visual Studio” and “Visual Studio Code” are not the same thing. Visual Studio is an integrated development environment (IDE) and Visual Studio Code is a rich text editor like Sublime Text and Atom.
How do I run a CLI command in Visual Studio code? ›To get an overview of the VS Code command-line interface, open a terminal or command prompt and type code --help . You will see the version, usage example, and list of command line options.
How do I change my default terminal? ›You can change the shell that new Terminal windows and tabs open with. In the Terminal app on your Mac, choose Terminal > Settings, then click General. Next to “Shells open with”, select “Command (complete path)”, then enter the complete path to the shell you want to use.
How do I customize VS Code integrated terminal? ›- Go to the settings (In VSCode obviously) On Windows/Linux - File > Preferences > Settings. On macOS - Code > Preferences > Settings. Shortcut (⌘,) Search (⇧⌘P) → “Preferences: Open Settings”
- Search for "workbench: color customizations" and open the settings.json file.
How to run npm on visual code? ›
...
You can run the following commands:
- npm install.
- npm start.
- npm test.
- npm build.
vscode-extension-vscode
This is the source code for the NPM vscode module. The funcionality of vscode module has been splitted into @types/vscode and vscode-test .
- load the existing node_modules tree from disk.
- clone the tree.
- fetch the package.json and assorted metadata and add it to the clone.
- walk the clone and add any missing dependencies.
- dependencies will be added as close to the top as is possible.
Once your terminal is open, you can open VS Code from it by typing $ code . Then hit enter . Once you hit enter , VS Code will now open.
Why use zsh instead of bash? ›Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.
How do I install terminal? ›- Install.
- Set your default terminal application.
- Set your default terminal profile.
- Add new profiles.
- Open a new tab.
- Invoke the command palette.
- Open a new pane.
- Configuration.
- Open a terminal window. On windows, open a Command Prompt window, on MacOS, open a terminal window.
- Navigate to the folder or file you want to open (using cd) ...
- Type "code" [path to file]
From the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter.
Why do people use Visual Studio Code instead of Visual Studio? ›VS Code is comparatively faster. Visual Studio has a free editor for developers to use but also comes with a better and paid IDE version. VS Code is completely free of cost and is open-source. VS engages the best and the most advanced IntelliSense.
Do I need both Visual Studio and Visual Studio Code? ›If you need to collaborate with team members on development or debugging, then Visual Studio is the better choice. If you need to do serious code analysis or performance profiling, or debug from a snapshot, then Visual Studio Enterprise will help you. VS Code tends to be popular in the data science community.
Is VS Code a IDE or compiler? ›
Visual Studio Code is a streamlined code editor with support for development operations like debugging, task running, and version control. It aims to provide just the tools a developer needs for a quick code-build-debug cycle and leaves more complex workflows to fuller featured IDEs, such as Visual Studio IDE.
How do I run CLI? ›- On a map, select Execute CLI Commands from the right-click menu, or select Actions > Execute CLI Commands from the map toolbar.
- Select the target devices. By default, this action applies to the existing devices on the map. ...
- Enter the CLI command. ...
- Click Run.
- Depending on the version of Windows you're using, perform one of the following steps: In Windows 10, open the Start menu, and then scroll to Visual Studio. ...
- Next, right-click either Visual Studio 2019 or Visual Studio 2022, and then select More > Run as administrator.
- Open the terminal application.
- List available shells by typing cat /etc/shells .
- Note down the path to bash such as /bin/bash.
- To update your account to use bash run chsh -s /bin/bash.
- Close terminal app.
- Open the terminal app again and verify that bash is your default shell.
You can open the terminal settings through the dropdown menu or by pressing Ctrl + , on your keyboard.
How do I make terminal The default terminal in Windows 10? ›- Open Windows Terminal and go to Settings > Startup. ...
- Click Startup and choose “Windows Terminal” as the Default terminal application from the dropdown menu.
- Click Save to save your changes.
To do so, open the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and enter Preferences: Open User Settings. Then set python.defaultInterpreterPath , which is in the Python extension section of User Settings, with the appropriate interpreter.
How do I open the integrated terminal in Visual Studio 2017? ›- A faster way to launch the terminal is to use the default keyboard shortcut Ctrl +`.
- We can use the context menu from the Solution Explorer to open the terminal at a specific file path.
Open the Command Palette on Windows or Linux with Ctrl + Shift + P . On macOS, use Cmd + Shift + P . Search for Session. Click on PowerShell: Show Session Menu.
How do I add bash terminal to Visual Studio code? ›- Open Visual Studio Code and press and hold Ctrl + ` to open the terminal.
- Open the command palette using Ctrl + Shift + P .
- Type - Select Default Profile.
- Select Git Bash from the options.
- Click on the + icon in the terminal window.
- The new terminal now will be a Git Bash terminal.
How do I open bash terminal in Visual Studio code? ›
Second way
Another way to select a default terminal is to open up a new terminal in VS Code. Next to the big plus sign, click on the dropdown and select “Select Default Profile“. From the dropdown select “Git Bash” and you're all set. Reopen a new terminal to make sure Git Bash opens up as default.
- Execute the PowerShell: Show Session Menu command from the command palette ( Ctrl-Shift-P ). ...
- Additionally, you may assign a keyboard shortcut to the command, by clicking the cog icon on the right edge of the command palette entry.
By contrast, the PowerShell Integrated Console is a special shell that comes with the PowerShell extension and offers integration with PowerShell code being edited, notably to provide linting and debugging support, among other features.
How do I use the command prompt instead of PowerShell Visual Studio code? ›...
It was showing Powershell but not Command Prompt, so I did the following steps to get Command Prompt in Visual Studio:
- View -> Command palette -> Toggle Integrated Terminal.
- Open terminal by shortcut ctrl + ` or View -> terminal.
- Write the command as cmd.exe and run.