您好,登錄后才能下訂單哦!
本文將為大家詳細(xì)介紹“VSCode launch.json中的各種替換變量指的是什么意思”,內(nèi)容步驟清晰詳細(xì),細(xì)節(jié)處理妥當(dāng),而小編每天都會(huì)更新不同的知識(shí)點(diǎn),希望這篇“VSCode launch.json中的各種替換變量指的是什么意思”能夠給你意想不到的收獲,請(qǐng)大家跟著小編的思路慢慢深入,具體內(nèi)容如下,一起去收獲新知識(shí)吧。
Visual Studio Code 是一個(gè)運(yùn)行于 OS X,Windows和 Linux 之上的,針對(duì)于編寫現(xiàn)代 web 和云應(yīng)用的跨平臺(tái)編輯器,它為開發(fā)者們提供了對(duì)多種編程語(yǔ)言的內(nèi)置支持,并且正如 Microsoft 在Build 大會(huì)的 keynote 中所指出的,這款編輯器也會(huì)為這些語(yǔ)言都提供了豐富的代碼補(bǔ)全和導(dǎo)航功能。
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)境變量
如果你能讀到這里,小編希望你對(duì)“VSCode launch.json中的各種替換變量指的是什么意思”這一關(guān)鍵問(wèn)題有了從實(shí)踐層面最深刻的體會(huì),具體使用情況還需要大家自己動(dòng)手實(shí)踐使用過(guò)才能領(lǐng)會(huì),如果想閱讀更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。