- Notifications
You must be signed in to change notification settings - Fork2.1k
Seamless VS Code Integration
To run Cmder shell as the VS Code terminal, follow the instructions below:
👉 Note: Before you continue, make sure to updateboth VS Code and Cmder to thelatest versions respectively, as the configuration has been changed in the recent versions.
PressCtrl +, (Control-Comma) to accessVS Code Settings, search for
terminal profiles windows, then clickEdit in settings.json.✅ Tip: You can also open the
settings.jsonfile fromCommand Pallet (Ctrl +Shift +P), typesettings.jsonand then hitEnter.In the
settings.jsonfile, append or modify the following terminal profile forCmderinto your configuration file:👉 Note: Please make sure that the
CMDER_ROOTenvironment variable isconfigured to the correct installation directory first. Alternatively, you can also substitute the%CMDER_ROOT%variable with the path to your Cmder installation, although this is not recommended."terminal.integrated.defaultProfile.windows":"Cmder","terminal.integrated.profiles.windows": {"Cmder": {"name":"Cmder","path": ["${env:windir}\\Sysnative\\cmd.exe","${env:windir}\\System32\\cmd.exe" ],"args": ["/k","${env:cmder_root}\\vendor\\bin\\vscode_init.cmd"],"icon":"terminal-cmd","color":"terminal.ansiGreen" }, },
example of using an absolute path instead of
CMDER_ROOTvariable:"args": ["/k","C:\\Cmder\\vendor\\bin\\vscode_init.cmd"]
The configured values will produce a default Cmder terminal using
Cmd.exe(i.e. clink) shell, as if you launchedCmder.exe.Tip: The
terminal.integrated.profiles.windowsandterminal.integrated.defaultProfile.windowsconfigs are only valid with Windows-based shells and will have no effect on other operating systems such as Linux and macOS, so you can safely share your VS Code config across different machines.✅ Note the double backslashes which are required. Alternatively, you can use a single forward slash (
/) instead of double slashes (\\) to specify the path.Also note that in the path value,
cmd.exemust be used instead ofcmder.exe. Seemore information for details.PressCtrl +` (Control-Tilde) to open VS Code's integrated terminal.
👉 Note: Cmder and VS Code both have a hotkey mapping forCtrl +` (Control-Tilde). You need to change Cmder's mapping if you want to use VS Code's mapping. You can readmore information about that.
A generic
vscode_init_args.cmdis created in one of the paths below on the first run ofvscode_init.cmd, if it does not already exist. This file is run every time you open VS Code's integrated terminal to access Cmder.Edit either the
%cmder_root%\bin\vscode_init_args.cmdor the%cmder_user_bin%\vscode_init_args.cmdscript to set appropriate Cmder settings for VS Code according to the internal documentation present in the script.User-configured Cmder
vscode_init_args.cmdexample:@echooffecho Applying Cmder VSCode settings from '%~0'...ifdefined CMDER_CONFIGURED (rem Set Cmder settings here for when VSCode is launched inside Cmder.rem The below causes Cmder to not rerun '%cmder_root%\config\profile.d\*.cmd' or 'user_profile.cmd' scripts because Cmder already ran them.setCMDER_CONFIGURED=2)else (rem Set Cmder settings here for when VSCode is launched from outside Cmder.rem Do NOT add optional Unix tools to the path the same as 'init.bat /nix_tools=0'setnix_tools=0rem Enable Cmder `fast_init` same as 'init.bat /f'setfast_init=1rem Enable Cmder User config same as 'Cmder.exe /c c:\Users\%USERNAME%\.cmder'rem NOTE: This is non-default config and results in a non-portable config.rem This is for example purposes only and should only be done if you understand WHY this is done!setcmder_user_bin=c:\Users\%USERNAME%\.cmder\binsetcmder_user_config=c:\Users\%USERNAME%\.cmder\config)setverbose_output=1rem Set all required Cmder VSCode terminal environment settings above this line.echo Applying Cmder VSCode settings is complete!
Close the previous VS Code Cmder terminal by typing
exitand then pressEnter in the terminal.PressCtrl +` (Control-Tilde) to open VS Code's terminal again.
👉 Note: The default example created by Cmder might cause some verbose information messages to be displayed every time you open the Cmder terminal in VS Code,please refer to this discussion for more information. You'll need to set
verbose_outputto0, and comment out anyecholines invscode_init_args.cmdthat you don't want to see, in order to mute these messages.
You may now use Cmder with VS Code.
For more support, read ourguide. Here's ademo.
⚠CAUTION: The command line interpreter in Windows has had some issues withspaces in the path, such asC:\Program Files (x86)\Cmder. We recommend installing Cmder in a path that doesn't contains spaces in order to avoid this.
If you have installed Cmder to a path with spaces, you might need to prepend a^ symbol before each space in the path values, such thatC:\\Example Directory with Spaces\\Cmder will becomeC:\\Example^ Directory^ with^ Spaces\\Cmder in yoursettings.json file.
You canalso 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 use8.3 filename convention, as a workaround:
C:\Program Files\Cmder → "C:\\PROGRA~1\\Cmder"(UsePROGRA~2 forProgram Files (x86))
VS Code is able to work in portable mode. To install it as portable, just follow theofficial instructions and configure Cmder accordingly.
Extract the VS Code zip file to
%CMDER_ROOT%\bin\vscodeCreate
%CMDER_ROOT%\bin\vscode\datato enable portable mode.Create the below file in
%cmder_root%\bin\vscode.cmdfor launching VS Code Portable from Cmder:@call "%cmder_root%\bin\vscode\bin\code.cmd"Start
Cmderand typevscode.ClickFile →Preferences, then clickEdit in settings.json.
Add the below configuration to
settings.json:"terminal.integrated.shell.windows":"cmd.exe","terminal.integrated.shellArgs.windows": ["/K","%CMDER_ROOT%/vendor/bin/vscode_init.cmd", ]
Microsoft has set PowerShell as the default shell for Windows 10 and 11. To integrate Cmder with VS Code using the PowerShell profile, use the following settings. Everything else is the same as above.
"terminal.integrated.defaultProfile.windows":"Cmder PowerShell","terminal.integrated.profiles.windows": ["Cmder PowerShell": {"name":"PowerShell","source":"PowerShell","args": ["-ExecutionPolicy","Bypass","-NoLogo","-NoProfile","-NoExit","-Command","Invoke-Expression '. ''${env:CMDER_ROOT}\\vendor\\profile.ps1'''"],"icon":"terminal-powershell","color":"terminal.ansiGreen"}, ]
✅Note the double backslashes which are required.
Of course, you can substitute${env:cmder_root} with the absolute path of the location of your installation directory, but we instead recommend todefine it.
For example, note thatC:\apps\cmder\ would be the value of%CMDER_ROOT% ($env:CMDER_ROOT in PowerShell).
You can setterminal.integrated.defaultProfile.windows to be eitherCmder orCmder PowerShell, so that you'll have access to both profiles while the one you choose will be set as the default.
Related to issue#1758, make sure your Cmder has the "%cexec%" feature.
Put VS Code into
%cmder_root%\bin\vsCodefolder for example(
%cmder_root%is the environment variable of your Cmder installation directory, same as above.)Use the following variables in the configuration file:
"args": ["/k","${env:cmder_root}\\vendor\\bin\\vscode_init.bat","/noautorun"],
Use the following commands in
user-profile.cmdto run VS Code at startup:%ccall%NOT"/noautorun""start""%cmder_root%\bin\vsCode\Code.exe%*"
Update or add the following to your user settings:
Note: Change[cmder_root] portion below with either the environment variable%cmder_root% or the absolute path to the installation folder for Cmder.
"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",
(This will give you access to the built-inbash shell, with GNU/Linux tools such asls,cp,mv,pwd, etc.)
👉 Note: Make sure to substitute[cmder_root] with your Cmder installation directory. You candefine an environment variable to use as[cmder_root].
Here's a list of unofficial extensions that you can install:
- VSCodeCmder – Commands for VS Code to make it easier to use in a keyboard-only workflow