-
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: Please make sure that
CMDER_ROOT
is configured under your Windows Paths, you can also substitute it with the path to your cmder installation. The below config produces a default Cmder terminal usingCmd.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.profiles.windows": { "cmder": { "path": "C:\WINDOWS\System32\cmd.exe", "args": ["/K", "C:\Cmder\vendor\bin\vscode_init.cmd"] } }
<br />
**Tip:** You can [define an environment variable](Setting-up-Environment-Variables) to use as `[cmder_root]`.
5. Press <kbd>Ctrl + `</kbd> (Control-Tilde) to open VS Code's terminal.
6. 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 of `vscode_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:
```bat
@echo off
echo Applying Cmder VSCode settings from '%~0'...
if defined 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.
set CMDER_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'
set nix_tools=0
rem Enable Cmder `fast_init` same as 'init.bat /f'
set fast_init=1
rem 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!
set cmder_user_bin=c:\Users\%USERNAME%\.cmder\bin
set cmder_user_config=c:\Users\%USERNAME%\.cmder\config
)
set verbose_output=1
rem 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 <kbd>Ctrl + `</kbd> (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`. <sup>[More…](https://github.com/cmderdev/cmder/issues/1984#issue-389879839)</sup>
👉 Cmder and VS Code both have a hotkey mapping for <kbd>Ctrl + `</kbd>. You need to change Cmder's mapping if you want to use VS Code's mapping. <sup>[More...](https://github.com/cmderdev/cmder/issues/1656#issuecomment-366301511)</sup>
For more information/issues, read our [guide](https://github.com/cmderdev/cmder/issues/1704). Here's a [demo](https://imgur.com/RKN3Avl).
### Spaces in path
⚠ **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](https://en.wikipedia.org/wiki/8.3_filename) convention:
C:\Program Files\Cmder → "C:\PROGRA~1\Cmder"
(Use `PROGRA~2` for `Program Files (x86)`)
### Install VS Code in portable mode
VS Code is able to work in portable mode. To install it as portable, just follow the [official instructions](https://code.visualstudio.com/docs/editor/portable) 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 type `vscode`.
* Click `File->Preferences`, find and click `Edit 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",
]
### Use PowerShell instead of cmd.exe
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.
```json
"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: