jsonvisual-studio-codevscode-code-runner

Where can I find settings-variable-reference visual studio code documentation ? (e.g : $fileName, $fileNameWithoutExt)


I'm using the Code Runner extension in vs code,

I want to change the output directory of compiled-cpp (.exe) files but I don't know what variable-name I will type in

"code-runner.executorMap": {
    
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", // <- this

Is anyone know where the variable-name documentation for this case ? anyway sorry for my bad english

I've tried to implement from https://code.visualstudio.com/docs/editor/variables-reference like this :

"cpp": "cd $dir && g++ $file -o $workspaceFolder\\C++\\bin\\$fileNameWithoutExt && $workspaceFolder\\C++\\bin\\$fileNameWithoutExt",

and I got : Unexpected token '\C++\bin\stringComparison' in expression or statement


Solution

  • formulahendry/vscode-code-runner: Code Runner for Visual Studio Code (github.com)

    Supported customized parameters

    • $workspaceRoot: The path of the folder opened in VS Code
    • $dir: The directory of the code file being run
    • $dirWithoutTrailingSlash: The directory of the code file being run without a trailing slash
    • $fullFileName: The full name of the code file being run
    • $fileName: The base name of the code file being run, that is the file without the directory
    • $fileNameWithoutExt: The base name of the code file being run without its extension
    • $driveLetter: The drive letter of the code file being run (Windows only)
    • $pythonPath: The path of Python interpreter (set by Python: Select Interpreter command)

    Please take care of the back slash and the space in file path of the executor

    • Back slash: please use \\
    • If there ares spaces in file path, please use \" to surround your file path