VSCode launch.json中的各种替换变量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等

WEB前端 waitig 962℃ 百度已收录 0评论

VS Code supports variable substitution inside strings in launch.json and has the following
predefined variables:

  • ${workspaceFolder} – the path of the folder opened in VS Code
  • ${workspaceRootFolderName} – the name of the folder opened in VS Code without any slashes (/)
  • ${file} – the current opened file
  • ${relativeFile} – the current opened file relative to workspaceRoot
  • ${fileBasename} – the current opened file’s basename
  • ${fileBasenameNoExtension} – the current opened file’s basename with no file extension
  • ${fileDirname} – the current opened file’s dirname
  • ${fileExtname} – the current opened file’s extension
  • ${cwd} – the task runner’s current working directory on startup
  • ${lineNumber} – the current selected line number in the active file

You can also reference environment variables through ${env:Name} syntax (for example, ${env:PATH}). Be sure to match
the environment variable name’s casing, for example ${env:Path} on Windows.

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "program": "${workspaceFolder}/app.js",
    "cwd": "${workspaceFolder}",
    "args": [ "${env:USERNAME}" ]
}

You can reference VS Code settings and commands using the following syntax:

  • ${config:Name} – example: ${config:editor.fontSize}
  • ${command:CommandID} – example: ${command:explorer.newFolder}

本文由【waitig】发表在等英博客
本文固定链接:VSCode launch.json中的各种替换变量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)