在哪里可以找到设置变量参考visual studio代码文档?(例如:$fileName、$fileNameWithou



我在vs Code、中使用Code Runner扩展

我想更改已编译的cpp(.exe)文件的输出目录,但我不知道我将在中键入什么变量名

  • 我的"settings.json";文件:
"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

有人知道这个案例的变量名文档在哪里吗?无论如何,很抱歉我的英语不好

我尝试从https://code.visualstudio.com/docs/editor/variables-reference像这样:

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

我得到了:表达式或语句中的意外标记"\C++\bin\stringComparison">

formulahendry/vscode代码运行程序:Visual Studio代码的代码运行程序(github.com)

支持的自定义参数

  • $workspaceRoot:在VS代码中打开的文件夹的路径
  • $dir:正在运行的代码文件的目录
  • $dirWithoutTrailingSlash:正在运行的代码文件的目录,没有尾部斜杠
  • $fullFileName:正在运行的代码文件的全名
  • $fileName:正在运行的代码文件的基本名称,即没有目录的文件
  • $fileNameWithoutExt:正在运行的代码文件的基本名称,没有扩展名
  • $driveLetter:正在运行的代码文件的驱动器号(仅限Windows)
  • $pythonPath:Python解释器的路径(由Python: Select Interpreter命令设置)

请注意执行程序的反斜杠和文件路径中的空格

  • 反斜杠:请使用\
  • 如果文件路径中有空格,请使用"包围您的文件路径

打开Visual Studio Code->Setting->Upper right corner->CCD_ 7,然后使用此命令编辑代码运行器executorMap CCD_。

"code-runner.executorMap": {
"cpp": "cd $dir && g++ -std=c++17 "$fileName" -o "$fileNameWithoutExt.o" && $dir"$fileNameWithoutExt.o"",
}

相关内容

最新更新