How to integrate Cmder properly in VS Code?

ramian picture ramian · Dec 18, 2018 · Viewed 7.1k times · Source

I would like to integrate Cmder shell into my VS Code configuration.

I'm using VS Code 64bit on Windows, and I tried to modify my settings.json file as follows, to make Cmder work as the integrated terminal:

"terminal.integrated.shell.windows": "C:\\Program Files\\Cmder\\Cmder.exe",

I restarted my VS Code and tried to open the terminal.

At first, this error message box showed up:

Failed to copy ConEmu.xml file to backup location!
Restart Cmder as administrator.

So, I launched VS Code as administrator, which made the error message disappear; however, I noticed that VS Code opens Cmder in another separate window instead of in the terminal.

How can I run Cmder shell inside VS Code terminal?

P.S. Could this note in vs code documentation be the solution?

Tip: The integrated terminal shell is running with the permissions of VS Code. If you need to run a shell command with elevated (administrator) or different permissions, you can use platform utilities such as runas.exe within a terminal."

from: https://code.visualstudio.com/docs/editor/integrated-terminal

Answer

David Refoua picture David Refoua · Jan 26, 2019

There is a mistake in your configuration file, the following is not valid:

"terminal.integrated.shell.windows": "C:\\Program Files\\Cmder\\Cmder.exe"

You should not be calling Cmder.exe from the VS Code, instead, you should use init.bat (from the instructions below) to integrate Cmder in VS Code.

Your issue has been already explained here over the Cmder repository.


Making Cmder work in VS Code

  1. Make sure you're on the latest release of Cmder – download latest here

  2. Open the settings.json configuration file, by pressing Ctrl + , (Control-Comma) to access the preferences, then click on the Edit in settings.json link

  3. VS Code documentation explains the process in this link:
    Can I use Cmder's shell with the terminal on Windows?

    Yes, to use the Cmder shell in VS Code, you need to add the following settings to your settings.json file:

    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "terminal.integrated.shellArgs.windows": ["/K", "C:\\cmder\\vendor\\init.bat"]
    
  4. BTW, You need to replace C:\\cmder with your own installation path.
    Tip: replace single backslashes (\) with double backslashes (\\).

  5. Make sure you read the notice at the official Cmder wiki:

    👉 Please note the use of cmd.exe instead of cmder.exe.

    Tip: refer to here on notes about handling spaces in your path.
    TL;DR: It's not recommended by the Cmder team, but you may use ^ character before spaces to handle the paths.

  6. You don't need to restart VS Code to make this work.
    Hit Ctrl + ` (Control-Tilde) to open Cmder in VS Code terminal!

You may refer to my answer here for a complete explanation of how this works.


Related

There are similar issues over the VS Code repo and here on Cmder repo as well.