-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Seamless VS Code Integration
To run Cmder as the VS Code terminal, you may follow these steps:
-
Press Ctrl + , to access
VSCode Settings
-
Search for
settings.json
-
Click
Edit in settings.json
-
Append or modify the following into your configuration file:
Note: The below config produces a default Cmder terminal using
Cmd.exe
shell as if you launchedCmder.exe
. Theterminal.integrated.env.windows
are only valid withCmd.exe
based shells and will have no effect if using Powershell or Bash."terminal.integrated.shell.windows": "cmd.exe", "terminal.integrated.shellArgs.windows": [ "/k", "%USERPROFILE%\\cmder\\vendor\\bin\\vscode_init.cmd" ],
Substitute both [cmder_root]
with your Cmder installation directory.
Tip: You can define an environment variable to use as [cmder_root]
.
-
Press Ctrl + ` (Control-Tilde) to open VS Code's terminal.
-
If you are running Cmder 1.3.16 or newer:
Note: A generic
vscode_init_args.cmd
is created in one of the paths below on first run ofvscode_init.cmd
if it does not already exist.-
Edit either the
%cmder_root%\"bin\vscode_init_args.cmd
or the%cmder_user_bin%\vscode_init_args.cmd
script to set appropriate Cmder settings for vscode according the scripts internal documentation.User Configured Cmder
vscode_init_args.cmd
Example:@echo off echo Applying Cmder VSCode settings from '%~0'... if defined CMDER_CONFIGURED ( :: Set Cmder settings here for when VSCode is launched inside Cmder. :: The below causes Cmder to not rerun userprofile.d\*.cmd and user_profile.cmd scripts becasue Cmder already ran them. set CMDER_CONFIGURED=2 ) else ( :: Set Cmder settings here for when VSCode is launched from outside Cmder. :: Do NOT add optional Unix tools to the path the same as `init.bat /nix_tools=0` set nix_tools=0 :: Enable Cmder `fast_init` same as `init.bat /f` set fast_init=1 :: Enable Cmder User config same as `Cmder.exe /c c:\users\dtgam\cmder_cfg" set cmder_user_bin=c:\users\dtgam\cmder_cfg\bin set cmder_user_config=c:\users\dtgam\cmder_cfg\config ) set verbose_output=1 :: Set all required Cmder VSCode terminal environment settings above this line. echo Applying Cmder VSCode settings is complete!
-
close the previous VSCode Cmder terminal by typing
exit[Enter]
in the terminal. -
Press Ctrl + ` (Control-Tilde) to open VS Code's terminal.
-
You may now use Cmder with VS Code.
👉 Please note the use of cmd.exe
instead of cmder.exe
. More…
👉 Cmder and VS Code both have a hotkey mapping for Ctrl + `. You need to change Cmder's mapping if you want to use VS Code's mapping. More...
For more information/issues, read our guide. Here's a demo.
⚠ CAUTION: The command line interpreter in Windows has some issues with spaces in the path, such as C:\Program Files (x86)\Cmder
. We do not recommended to install Cmder in a path that contains spaces.
Instead, we recommend installing Cmder in a path that does not contain any spaces, such as: C:\apps\Cmder
or C:\tools\Cmder
to avoid any conflicts with VS Code.
If you for some reason really need to launch Cmder from a path with spaces, you might need to prepend a ^
symbol before each space, such that C:\\Example Directory with Spaces\\Cmder
will become C:\\Example^ Directory^ with^ Spaces\\Cmder
in your settings.json
file.
You may also have to escape the parentheses (
and )
as well as spaces. Here's an example:
C:\Program Files (x86)\Cmder → "C:\\Program^ Files^ ^(x86^)\\Cmder"
💾 Alternatively you could use 8.3 filename convention:
C:\Program Files\Cmder → "C:\\PROGRA~1\\Cmder"
(Use PROGRA~2
for Program Files (x86)
)
VS Code is able to work in portable mode. To install it as portable, just follow the official instructions and configure Cmder accordingly.
-
Extract the VSCode zip file to
%CMDER_ROOT%\bin\vscode
-
Create
%CMDER_ROOT%\bin\vscode\data
to enable portable mode. -
Create the below file in
%cmder_root%\bin\vscode.cmd
for launching VS Code Portable from Cmder:@call "%cmder_root%\bin\vscode\bin\code.cmd"
-
Start
Cmder
and typevscode
. -
Click
File->Preferences
, find and clickEdit in settings.json
. -
Add the below to
settings.json
"terminal.integrated.shell.windows": "cmd.exe", "terminal.integrated.shellArgs.windows": [ "/K", "%CMDER_ROOT%/vendor/bin/vscode_init.cmd", ]
Microsoft is trying to make PowerShell as the default shell for Windows 10. To integrate Cmder with VSCode using PowerShell, use the following settings. Everything else is the same as above.
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": [
"-ExecutionPolicy", "Bypass",
"-NoLogo", "-NoProfile", "-NoExit",
"-Command", ". 'C:\\apps\\cmder\\vendor\\conemu-maximus5\\\\..\\\\profile.ps1'"
]
Of course, you should set the location of the profile.ps1
file according to your installation directory.
✅ Note the double backslashes which are required.
Also note that C:\apps\cmder\vendor\conemu-maximus5
would be the value of %ConEmuDir%
($env:ConEmuDir
in PowerShell), but that environment variable is not available to VSCode unless you define it.
Related to issue #1758, make sure your Cmder have the "%cexec%" feature.
In my case:
- I put vsCode into
%cmder_root%\bin\vsCode
folder,
(%cmder_root%
is the environment variable of your Cmder installation directory.)
- I use the following variables as my configuration file:
"terminal.integrated.shellArgs.windows": [
"/k",
"%cmder_root%\\vendor\\bin\\vscode_init.bat",
"/noautorun"
],
- I use the following commands in
user-profile.cmd
to run vsCode at startup:
%ccall% NOT "/noautorun" "start" "%cmder_root%\bin\vsCode\Code.exe %*"
- Press Ctrl + , to access
VSCode Settings
- Search for
settings.json
- Click
Edit in settings.json
- Update or add the following to your user settings:
"git.enabled": true,
"git.path": "[cmder_root]\\vendor\\git-for-windows\\cmd\\git.exe",
if it does not work, you can try another way
"terminal.integrated.shell.windows": "[cmder_root]\\vendor\\git-for-windows\\bin\\bash.exe",
Substitute [cmder_root]
with your Cmder installation directory.
Tip: You can define an environment variable to use as [cmder_root]
.
Here's a list of unofficial extensions that you can install:
- VSCodeCmder – Commands for VSCode to make it easier to use in a keyboard-only workflow
There is currently an issue regarding the VS Code Tasks with Cmder. More info: