淺析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ù)腳本時(shí),可能會(huì)用到。本文以launch.json腳本為例,介紹各個(gè)變量的含義。
假設(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}:文件自身的絕對(duì)路徑,也即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)所在的行號(hào)
${env:PATH}:系統(tǒng)中的環(huán)境變量
更新一個(gè)鏈接:https://code.visualstudio.com/docs/editor/variables-reference
總結(jié)
到此這篇關(guān)于VSCode launch.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等的文章就介紹到這了,更多相關(guān)VSCode launch.json 替換變量?jī)?nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Qt實(shí)現(xiàn)手動(dòng)切換多種布局的完美方案
通過(guò)點(diǎn)擊程序界面上不同的布局按鈕,使主工作區(qū)呈現(xiàn)出不同的頁(yè)面布局,多個(gè)布局之間可以通過(guò)點(diǎn)擊不同布局按鈕切換,支持的最多的窗口為9個(gè),不同布局下窗口數(shù)隨之變化,這篇文章主要介紹了Qt實(shí)現(xiàn)手動(dòng)切換多種布局的完美方案,需要的朋友可以參考下2024-07-07Linux UDP服務(wù)端和客戶端程序的實(shí)現(xiàn)
這篇文章主要介紹了Linux UDP服務(wù)端和客戶端程序的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05Qt重寫QTreeView自繪實(shí)現(xiàn)酷炫樣式
QTreeView,顧名思義,就是一種樹(shù)形的控件,在我們需要做類似于文件列表的視圖時(shí),是一個(gè)不錯(cuò)的選擇,下面我們就來(lái)看看qt如何重寫QTreeView實(shí)現(xiàn)酷炫樣式,感興趣的可以了解一下2023-08-08Qt重寫QStackedWidget模擬實(shí)現(xiàn)home界面滑動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Qt如何通過(guò)重寫QStackedWidget模擬實(shí)現(xiàn)home界面滑動(dòng)效果,文中的實(shí)現(xiàn)過(guò)程講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2022-11-11C語(yǔ)言中全局?jǐn)?shù)組和局部數(shù)組的問(wèn)題
今天同學(xué)遇到一個(gè)在C語(yǔ)言中全局?jǐn)?shù)組和局部數(shù)組的問(wèn)題,卡了許久,我也沒(méi)有第一時(shí)間看出問(wèn)題,現(xiàn)在把問(wèn)題梳理一下,并給出解決方案,需要的朋友可以參考下2012-12-12探究在C++程序并發(fā)時(shí)保護(hù)共享數(shù)據(jù)的問(wèn)題
這篇文章主要介紹了探究在C++程序并發(fā)時(shí)保護(hù)共享數(shù)據(jù)的問(wèn)題,也有利于大家更好地理解C++多線程的一些機(jī)制,需要的朋友可以參考下2015-07-07