Vscode-code-runner: How to add entry into code-runner.executorMap?

Created on 10 Feb 2018  路  11Comments  路  Source: formulahendry/vscode-code-runner

In the configuration section it says to:

You could also add entry into code-runner.executorMap to set the executor PATH. e.g. To set the executor PATH for ruby, php and html:

How do I add this entry to that file. I can't find it in any directory or through VScode.

Thanks!

question

Most helpful comment

Go Extension -> Click "Code Runner" 's gear icon -> Click "Configure Extension Settings" -> Search "Code-runner: Executor Map" -> Click "Edit in settings.json" then you will see a .json code like this(could be different depending on your system setting)

{
    "C_Cpp.updateChannel": "Insiders",
    "editor.fontSize": 14,
    "window.zoomLevel": 0,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": true,
    "code-runner.runInTerminal": true,
    "C_Cpp.default.cppStandard": "c++14",
    "C_Cpp.default.cStandard": "c11",
}

You can add entry like this. "code-runner.executorMap": { ~

 {
    "C_Cpp.updateChannel": "Insiders",
    "editor.fontSize": 14,
    "window.zoomLevel": 0,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": true,
    "code-runner.runInTerminal": true,
    "C_Cpp.default.cppStandard": "c++14",
    "C_Cpp.default.cStandard": "c11",
    "code-runner.executorMap": {
        "javascript": "node",
        "php": "C:\\php\\php.exe",
        "python": "python",
        "perl": "perl",
        "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
        "go": "go run",
        "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ -std=c++14 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    }
}

I set this for modern c++ environment setting. hope this helpful :)

All 11 comments

Hi @articulatesnail , please refer to https://code.visualstudio.com/docs/getstarted/settings#_creating-user-and-workspace-settings

But how to do it?

Hi @articulatesnail , please refer to https://code.visualstudio.com/docs/getstarted/settings#_creating-user-and-workspace-settings

That link shows how to replace the entire map. Its does not show how to modify/add a single entry.

That link shows how to replace the entire map. Its does not show how to modify/add a single entry.

Hello @articulatesnail , I also had this issue. I took the entire map and replaced it. I only changed/modified the entries I needed and left the rest as original.

I am new to python and VS Code. Where is the code-runner.executorMap file located? I am on Unix.

Open your global settings (Ctrl+Shift+P or Ctrl+,) and then enter "code-run" in the search box.

Scroll down through the results and choose "Edit in settings.json" under the "Executor Map" that you would like to edit. (e.g. Global, by File Extension, by Glob)

Under my install, the specific "Setting ID" I was looking for was titled:
code-runner.executorMapByFileExtension

Go to the users//"Username"//.vscode//extensions//"The code runner name"//package.json and edit it there

Go Extension -> Click "Code Runner" 's gear icon -> Click "Configure Extension Settings" -> Search "Code-runner: Executor Map" -> Click "Edit in settings.json" then you will see a .json code like this(could be different depending on your system setting)

{
    "C_Cpp.updateChannel": "Insiders",
    "editor.fontSize": 14,
    "window.zoomLevel": 0,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": true,
    "code-runner.runInTerminal": true,
    "C_Cpp.default.cppStandard": "c++14",
    "C_Cpp.default.cStandard": "c11",
}

You can add entry like this. "code-runner.executorMap": { ~

 {
    "C_Cpp.updateChannel": "Insiders",
    "editor.fontSize": 14,
    "window.zoomLevel": 0,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": true,
    "code-runner.runInTerminal": true,
    "C_Cpp.default.cppStandard": "c++14",
    "C_Cpp.default.cStandard": "c11",
    "code-runner.executorMap": {
        "javascript": "node",
        "php": "C:\\php\\php.exe",
        "python": "python",
        "perl": "perl",
        "ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
        "go": "go run",
        "html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ -std=c++14 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    }
}

I set this for modern c++ environment setting. hope this helpful :)

what should i change in mac OS for html?
Screenshot 2020-06-24 at 05 21 54

@niemand20
Frist, I recommend to use 'alias' command to execute chrome app on command, then you can add this command to code-runner executorMap. the screenshot below explains all.
Screen Shot 2020-07-11 at 2 53 40 PM
Screen Shot 2020-07-11 at 2 54 02 PM

reference
https://apple.stackexchange.com/questions/83630/create-a-terminal-command-to-open-file-with-chrome

Im using windows and i hate it filesystem because i use git bash as default terminal and if i want to compile c++ i need to do it manually. Command is cd "d:\folder1\folder 2"\ but reversed slash can be used to add spaces or other symbols to command, but using it without "". I can write "hello world" or hello\ world. And because that i cant set it to normal. help

Was this page helpful?
3 / 5 - 1 ratings

Related issues

seiferthan picture seiferthan  路  4Comments

manikantag picture manikantag  路  4Comments

sstorey-nephila picture sstorey-nephila  路  5Comments

Yensan picture Yensan  路  4Comments

Kelo007 picture Kelo007  路  3Comments