46

職場では、すべての実行可能ファイルがC:\Program FilesまたはC:\Program Files (x86).

Visual Studio Code でsettings.json、次の設定を使用します。

{
    "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k C:\\Program Files (x86)\\Cmder\\vendor\\init.bat"
    ]
}

...統合端末の初期化時に、次のエラー メッセージが表示されます。

'C:\Program' is not recognized as an internal or external command, 
operable program or batch file.

Program FileWindows の優れたファイル/ディレクトリ命名規則により、スペースを使用できるため、パスの 1 つを指すのは困難です。

VSCode は、スペース文字をエスケープすると気に入らず、このコードでエラーが発生しますInvalid escape character in string。プロパティをこれに変更しようとすると:

{
    ...
    "terminal.integrated.shellArgs.windows": [
        "/k C:\\Program\ Files\ (x86)\\Cmder\\vendor\\init.bat"
    ]
}

...次のエラー メッセージが表示されます。

'C:\ProgramFiles' is not recognized as an internal or external command,
operable program or batch file.

最後に、次のようにパスを引用符で囲みます。

{
    ...
    "terminal.integrated.shellArgs.windows": [
        "/k \"C:\\Program Files (x86)\\Cmder\\vendor\\init.bat\""
    ]
}

...このエラーメッセージが表示されます:

'\"C:\Program Files (x86)\Cmder\vendor\init.bat\""' is not recognized as an 
internal or external command,
operable program or batch file.

Cmder を VSCode に統合する方法はありますか?

4

14 に答える 14

74

インターネットで答えを探した後、解決策を見つけることができませんでしたが、別のフォーラムの人々が同じ質問をしていたのを見たので、他の人が見ることができるようにここに投稿するかもしれないと考えましたが、解決策はありませんでした。答え。

Windows では、次のコマンドの/Xfor があります。dir

  /X          This displays the short names generated for non-8dot3 file
              names.  The format is that of /N with the short name inserted
              before the long name. If no short name is present, blanks are
              displayed in its place.

したがって、dir /Xコマンドを on実行C:\すると、次のように表示されます。

C:\>dir /X
 Volume in drive C is OSDisk
 Volume Serial Number is XXXX-XXXX

 Directory of C:\

...
08/17/2017  08:02 PM    <DIR>          PROGRA~1     Program Files
08/09/2017  03:58 PM    <DIR>          PROGRA~2     Program Files (x86)
...

ディレクトリの短い名前PROGRA~2を使用して を置き換え、 VS CodeProgram Files (x86)で次の設定を行うことができます。settings.json

{
    "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k C:\\PROGRA~2\\Cmder\\vendor\\init.bat"
    ]
}

統合ターミナルでCmderを正常にロードするのはどれですか:

Cmder が VS Code 統合ターミナルに正常にロードされているイメージ。

于 2017-08-18T22:34:56.050 に答える
2

Cmder with VSCode 2021

  • Step 1: Download Cmder
  • Step 2: Save Cmder to C:\cmder
  • Step 3: Open Settings.json in VSCode
  • Step 4: Create VSCode Integrated Terminal Settings
"terminal.integrated.profiles.windows": {
    "Cmder": {
      "path": "${env:windir}\\System32\\cmd.exe",
      "args": ["/k", "C:\\cmder\\vendor\\bin\\vscode_init.cmd"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "Cmder",
  • Step 5: restart VSCode
  • Step 6: Happy coding!
于 2021-09-17T14:39:21.150 に答える
0

このソリューションは、開いている端末では適切ですが、npm build - lint などの引数を使用してプラグインを介して起動された cmd 呼び出しを中断します。

これを修正する解決策は、これらの呼び出しをラップし、sellArgs で参照するカスタム init.bat を作成することです。

設定.json

"terminal.integrated.shell.windows": "cmd.exe",
"terminal.integrated.shellArgs.windows": [
    "/K C:\\SoftDev\\App\\Cmder\\vendor\\vstudio.bat"
],

C:\SoftDev\App\cmder\vendor\vstudio.bat

@echo off
if "%1" == "" (
    C:\SoftDev\App\cmder\vendor\init.bat
) else (
    cmd %1 %2 %3 %4 %5 %6 %7 %8 %9
    exit
)
于 2019-08-09T10:12:38.593 に答える
0

私が見つけた最良の解決策:速くて簡単。

"terminal.external.windowsExec": "C:\\Utils\\Cmder\\Cmder.exe",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\cmd.exe"
"terminal.integrated.shellArgs.windows" : ["/K","C:\\Utils\\cmder\\vendor\\init.bat"],
于 2019-07-29T14:00:51.103 に答える
-1

Windows のコマンド ライン インタープリターには、C:\Program Files\Cmder や C:\Program Files (x86)\Cmder などのパスのスペースに関する問題があります。代わりに、「apps」のような新しいフォルダーを作成し、c:\apps のようにパスにスペースがないことを使用します

于 2020-02-20T17:24:12.427 に答える