淺析VSCode launch.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等
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}
在vscode中定義了一些變量,在配置任務(wù)腳本時,可能會用到。本文以launch.json腳本為例,介紹各個變量的含義。
假設(shè)當(dāng)前workspace的路徑為:"C:\Users\admin\Desktop\test",workspace文件夾下的結(jié)構(gòu)如下(+表示下一層):
C:\Users\admin\Desktop\test
+.vscode
++tasks.json
++launch.json
+main.cpp
${workspaceFolder} :表示當(dāng)前workspace文件夾路徑,也即C:\Users\admin\Desktop\test
${workspaceRootFolderName}:表示workspace的文件夾名,也即test
${file}:文件自身的絕對路徑,也即C:\Users\admin\Desktop\test\.vscode\launch.json
${relativeFile}:文件在workspace中的路徑,也即.vscode\launch.json
${fileBasenameNoExtension}:當(dāng)前文件的文件名,不帶后綴,也即launch
${fileBasename}:當(dāng)前文件的文件名,launch.json
${fileDirname}:文件所在的文件夾路徑,也即C:\Users\admin\Desktop\test\.vscode
${fileExtname}:當(dāng)前文件的后綴,也即.json
${lineNumber}:當(dāng)前文件光標(biāo)所在的行號
${env:PATH}:系統(tǒng)中的環(huán)境變量
更新一個鏈接:https://code.visualstudio.com/docs/editor/variables-reference
總結(jié)
到此這篇關(guān)于VSCode launch.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等的文章就介紹到這了,更多相關(guān)VSCode launch.json 替換變量內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Qt圖形圖像開發(fā)之曲線圖模塊QCustomplot庫生成靜態(tài)、動態(tài)曲線詳細(xì)教程圖解
這篇文章主要介紹了Qt圖形圖像開發(fā)之曲線圖模塊QCustomplot庫畫靜態(tài)、動態(tài)曲線詳細(xì)教程圖解,需要的朋友可以參考下2020-03-03
OpenCV實(shí)現(xiàn)鼠標(biāo)框選并顯示框選區(qū)域
這篇文章主要為大家詳細(xì)介紹了OpenCV實(shí)現(xiàn)鼠標(biāo)框選并顯示框選區(qū)域,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-08-08
C語言中如何實(shí)現(xiàn)單鏈表刪除指定結(jié)點(diǎn)
這篇文章主要介紹了C語言中如何實(shí)現(xiàn)單鏈表刪除指定結(jié)點(diǎn),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-07-07
實(shí)例詳解C/C++中extern關(guān)鍵字
這篇文章主要介紹了C/C++中extern關(guān)鍵字詳解 的相關(guān)資料,需要的朋友可以參考下2016-04-04
C語言文件操作 fopen, fclose, mkdir詳解
本文給大家詳細(xì)介紹了下C語言的文件操作函數(shù)fopen, fclose, mkdir的用法及示例,非常的簡單實(shí)用,有需要的小伙伴可以參考下。2016-03-03

