如何在VS Code中正确集成Cmder?

时间:2018-12-18 13:00:31

标签: visual-studio-code cmder

我想将Cmder外壳集成到我的VS Code配置中。

我在Windows上使用VS Code 64位,并且尝试按如下所示修改我的settings.json文件,以使Cmder用作集成终端:

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

我重新启动了VS Code,并尝试打开终端。

首先,出现此错误消息框:

  

无法将ConEmu.xml文件复制到备份位置!
  以管理员身份重新启动Cmder。

因此,我以管理员身份启动了VS Code,这使错误消息消失了;但是,我注意到VS Code在另一个单独窗口中而不是在终端中打开Cmder。

如何在VS Code终端中运行Cmder shell?

P.S。 vs代码文档中的注释是否可以解决?

  

提示:集成终端外壳正在VS Code的许可下运行。如果您需要以提升的(管理员)权限或其他权限运行shell命令,则可以在终端中使用runas.exe之类的平台实用程序。“

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

4 个答案:

答案 0 :(得分:1)

Cmder 1.3.12引入了vscode_init.cmd脚本,该脚本允许VS Code任务与Cmder一起正常工作。

如果您使用的Cmder版本大于1.3.11,则以上答案中提到的VS Code文档已过时。

Cmder GitHub存储库中现在有extensive documentation关于如何实现Cmder和VS Code之间的集成。在编写此消息时,它比the VS Code documentation更准确。

答案 1 :(得分:1)

以下是对我有用的东西:

  1. 将\ cmder目录粘贴到C:\ tools

  2. 粘贴到.vscode \ settings.json中:

    "terminal.integrated.shell.windows": "cmd.exe",
    "terminal.integrated.env.windows": {
        "CMDER_ROOT": "C:\\tools\\cmder"
    },
    "terminal.integrated.shellArgs.windows": [
        "/k",
        "%CMDER_ROOT%\\vendor\\init.bat"
    ],
    

..尽情享受吧!

答案 2 :(得分:0)

您的配置文件中有一个错误,以下内容无效有效:

a.flip().and(b)

您不应该从VS Code调用 Cmder.exe ,而是应该使用#include <stdio.h> int findMinpos(int arr[], int mid, int len){ int minimum; if(len==1) return arr[0+mid]; else { minimum = findMinpos(arr, mid, len-1); if(minimum<arr[len-1]) return minimum; else return arr[len-1]; } } int main(void) { int array[7]= {23,17,8,7,9,32,56}; printf("%d", findMinpos(array, 2, 7)); return 0; } (根据以下说明)将Cmder集成到VS代码。

您的问题已经在Cmder存储库中here进行了说明。


使用VS Code使Cmder工作

  1. 确保您使用的是Cmder的最新版本–下载最新的here

  2. 打开"terminal.integrated.shell.windows": "C:\\Program Files\\Cmder\\Cmder.exe" 配置文件,方法是按 Ctrl + (按Control-逗号)以访问首选项,然后单击< strong>在settings.json中编辑链接

  3. VS Code文档解释了此链接中的过程:
    Can I use Cmder's shell with the terminal on Windows?

      

    是的,要在VS Code中使用Cmder shell,您需要在init.bat文件中添加以下设置:

         
    settings.json
  4. 顺便说一句,您需要用自己的安装路径替换settings.json
    提示:将单反斜杠("terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe", "terminal.integrated.shellArgs.windows": ["/K", "C:\\cmder\\vendor\\init.bat"] )替换为双反斜杠(C:\\cmder)。

  5. 确保您已在官方Cmder wiki上阅读了该通知:

      

    请注意使用\而不是\\

    提示:请参阅here,了解有关处理路径中空格的说明。
    TL; DR:Cmder团队不建议这样做,但是您可以在空格前使用cmd.exe字符来处理路径。

  6. 您无需重新启动VS Code即可完成此工作。
    点击 Ctrl + `(按Control-Tilde)以在VS Code终端中打开Cmder!

您可以参考我的答案here以获得有关其工作原理的完整说明。


相关

也有类似的问题over the VS Code repohere on Cmder repo

答案 3 :(得分:0)

这在 2021 年 6 月 22 日对我有用;将这些行添加到您的用户设置中的 settings.json 文件中(对我来说 « C:\Users\ianla\AppData\Roaming\Code\User\settings.json »):

"terminal.integrated.profiles.windows": {
    "cmder": {
      "path": "C:\\WINDOWS\\System32\\cmd.exe",
      "args": ["/K", "C:\\Users\\ianla\\cmder\\vendor\\bin\\vscode_init.cmd"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "cmder",

...当然,您需要使用安装“cmder”安装路径更改我的«C:\Users\ianla\»。

See here for more info

相关问题