运行 cmd 上编译后的程序(vscode 上的代码 运行ner 插件)

Run a program on cmd right after compilation (Code Runner plugin on vscode)

我安装了 Code Runner 来编译我的 C 代码。 我希望 .exe 像 Visual Studio 那样编译程序后直接在我的 cmd 上打开。

我该怎么做?

正如它在 marketplace

中提到的

转到 VS Code > 首选项:

  • 然后输入:Code Runner

您会看到 Code-Runner: Executor-Map 单击 在 settings.json 中编辑,您会看到类似这样的内容:

{
    "window.zoomLevel": 0,
    "C_Cpp.updateChannel": "Insiders",
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "workbench.iconTheme": "material-icon-theme",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.checkProjectSettingsExclusions": false,
    "explorer.confirmDelete": false,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "explorer.confirmDragAndDrop": false
}

然后在 "explorer.confirmDragAndDrop": false 下方添加,如下所示:

{
    "window.zoomLevel": 0,
    "C_Cpp.updateChannel": "Insiders",
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "workbench.iconTheme": "material-icon-theme",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.checkProjectSettingsExclusions": false,
    "explorer.confirmDelete": false,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "explorer.confirmDragAndDrop": false,
    "code-runner.executorMap": {
        "javascript": "nodejs",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && start $dir$fileName"
    }
}

恭喜你:)