Skip to content

Seamless VS Code Integration

Ciro Mora edited this page Aug 21, 2019 · 28 revisions

VS Code Terminal

To run Cmder as the VS Code terminal, you may follow these steps:

  1. Press Ctrl + , to access VSCode Settings
  2. Search for settings.json
  3. Click Edit in settings.json
  4. Append or modify the following into your configuration file:
  "terminal.integrated.shell.windows": "cmd.exe",

  "terminal.integrated.env.windows": {
  "CMDER_ROOT": "[cmder_root]"
  },
  "terminal.integrated.shellArgs.windows": [
    "/k",
    "[cmder_root]\\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].

  1. 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.

 

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 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 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.

    "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.

 

Automatically open vsCode at startup, as well as use its build-in terminal

Related to issue #1758, make sure your Cmder have the "%cexec%" feature.

In my case:

  1. I put vsCode into %cmder_root%\bin\vsCode folder,

(%cmder_root% is the environment variable of your Cmder installation directory.)

  1. I use the following variables as my configuration file:
"terminal.integrated.shellArgs.windows": [
  "/k",
  "%cmder_root%\\vendor\\bin\\vscode_init.bat",
  "/noautorun"
],
  1. I use the following commands in user-profile.cmd to run vsCode at startup:
%ccall% NOT "/noautorun" "start" "%cmder_root%\bin\vsCode\Code.exe %*"

 

Use Cmder Embedded Git in VSCode

  1. Press Ctrl + , to access VSCode Settings
  2. Search for settings.json
  3. Click Edit in settings.json
  4. 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].

Optional Steps

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

Known Issues

VS Code Tasks

There is currently an issue regarding the VS Code Tasks with Cmder. More info:

You can’t perform that action at this time.