淺析VSCode tasks.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等
When authoring tasks configurations, it is often useful to have a set of predefined common variables. VS Code supports variable substitution inside strings in the tasks.json file and has the following predefined variables:
- ${workspaceFolder} the path of the workspace folder that contains the tasks.json file
- ${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 the workspace folder containing the file
- ${fileBasename} the current opened file's basename
- ${fileBasenameNoExtension} the current opened file's basename without the 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} (for example, ${env:PATH}). Be sure to match the environment variable name's casing, for example ${env:Path} on Windows.
Below is an example of a custom task configuration that passes the current opened file to the TypeScript compiler.
{
"taskName": "TypeScript compile",
"type": "shell",
"command": "tsc ${file}",
"problemMatcher": [
"$tsc"
]
}
部分翻譯:(來(lái)自互聯(lián)網(wǎng))
${workspaceRoot} 當(dāng)前打開(kāi)的文件夾的絕對(duì)路徑+文件夾的名字
${workspaceRootFolderName} 當(dāng)前打開(kāi)的文件夾的名字
${file}當(dāng)前打開(kāi)正在編輯的文件名,包括絕對(duì)路徑,文件名,文件后綴名
${relativeFile}從當(dāng)前打開(kāi)的文件夾到當(dāng)前打開(kāi)的文件的路徑
如 當(dāng)前打開(kāi)的是test文件夾,當(dāng)前的打開(kāi)的是main.c,并有test / first / second / main.c
那么此變量代表的是 first / second / main.c
${fileBasename} 當(dāng)前打開(kāi)的文件名+后綴名,不包括路徑
${fileBasenameNoExtension} 當(dāng)前打開(kāi)的文件的文件名,不包括路徑和后綴名
${fileDirname} 當(dāng)前打開(kāi)的文件所在的絕對(duì)路徑,不包括文件名
${fileExtname} 當(dāng)前打開(kāi)的文件的后綴名
${cwd} the task runner's current working directory on startup
不知道怎么描述,這是原文解釋,
跟 cmd 里面的 cwd 是一樣的
${lineNumber} 當(dāng)前打開(kāi)的文件,光標(biāo)所在的行數(shù)
更新一個(gè)鏈接:https://code.visualstudio.com/docs/editor/variables-reference
總結(jié)
到此這篇關(guān)于淺析VSCode tasks.json中的各種替換變量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等的文章就介紹到這了,更多相關(guān)VSCode tasks.json 替換變量?jī)?nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Qt中QtWebEngine加載本地網(wǎng)頁(yè)跨域問(wèn)題的總結(jié)
本文主要介紹了Qt中QtWebEngine加載本地網(wǎng)頁(yè)跨域問(wèn)題的總結(jié),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-04-04
C++簡(jiǎn)明分析臨時(shí)對(duì)象是什么
對(duì)性能來(lái)說(shuō),許多的問(wèn)題都需要和出現(xiàn)頻率及本身執(zhí)行一次的開(kāi)銷(xiāo)掛鉤,有些問(wèn)題雖然看似比較開(kāi)銷(xiāo)較大,但是很少會(huì)執(zhí)行到,那也不會(huì)對(duì)程序有大的影響;同樣一個(gè)很小開(kāi)銷(xiāo)的函數(shù)執(zhí)行很頻繁,同樣會(huì)對(duì)程序的執(zhí)行效率有很大影響。本章中作者主要根據(jù)臨時(shí)對(duì)象來(lái)闡述這樣一個(gè)觀點(diǎn)2022-04-04
c++如何實(shí)現(xiàn)歸并兩個(gè)有序鏈表
這篇文章主要介紹了c++如何實(shí)現(xiàn)歸并兩個(gè)有序鏈表,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-07-07
實(shí)現(xiàn)C語(yǔ)言常用字符串庫(kù)函數(shù)
這篇文章主要為大家介紹了如何實(shí)現(xiàn)C語(yǔ)言常用字符串庫(kù)函數(shù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助2021-11-11
C++分步實(shí)現(xiàn)職工管理系統(tǒng)詳解
這篇文章主要為大家詳細(xì)介紹了基于C++實(shí)現(xiàn)職工管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-10-10
C++ HLSL實(shí)現(xiàn)簡(jiǎn)單的圖像處理功能
本文主要介紹了HLSL實(shí)現(xiàn)簡(jiǎn)單的圖像處理功能的方法,具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-02-02
C++實(shí)現(xiàn)LeetCode(150.計(jì)算逆波蘭表達(dá)式)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(150.計(jì)算逆波蘭表達(dá)式),本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07
簡(jiǎn)單掌握C++編程中的while與do-while循環(huán)語(yǔ)句使用
這篇文章主要介紹了C++編程中的while與do-while循環(huán)語(yǔ)句使用,區(qū)別就是while是先判斷再執(zhí)行,而do-while是先執(zhí)行再判斷,需要的朋友可以參考下2016-01-01
C語(yǔ)言實(shí)現(xiàn)的bitmap位圖代碼分享
這篇文章主要介紹了C語(yǔ)言實(shí)現(xiàn)的bitmap位圖代碼分享,位圖(bitmap)是一種非常常用的結(jié)構(gòu),在索引、數(shù)據(jù)壓縮等方面有廣泛應(yīng)用,需要的朋友可以參考下2014-08-08

