淺析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中定義了一些變量,在配置任務腳本時,可能會用到。本文以launch.json腳本為例,介紹各個變量的含義。
假設當前workspace的路徑為:"C:\Users\admin\Desktop\test",workspace文件夾下的結(jié)構(gòu)如下(+表示下一層):
C:\Users\admin\Desktop\test
+.vscode
++tasks.json
++launch.json
+main.cpp
${workspaceFolder} :表示當前workspace文件夾路徑,也即C:\Users\admin\Desktop\test
${workspaceRootFolderName}:表示workspace的文件夾名,也即test
${file}:文件自身的絕對路徑,也即C:\Users\admin\Desktop\test\.vscode\launch.json
${relativeFile}:文件在workspace中的路徑,也即.vscode\launch.json
${fileBasenameNoExtension}:當前文件的文件名,不帶后綴,也即launch
${fileBasename}:當前文件的文件名,launch.json
${fileDirname}:文件所在的文件夾路徑,也即C:\Users\admin\Desktop\test\.vscode
${fileExtname}:當前文件的后綴,也即.json
${lineNumber}:當前文件光標所在的行號
${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重寫QStackedWidget模擬實現(xiàn)home界面滑動效果
這篇文章主要為大家詳細介紹了Qt如何通過重寫QStackedWidget模擬實現(xiàn)home界面滑動效果,文中的實現(xiàn)過程講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2022-11-11探究在C++程序并發(fā)時保護共享數(shù)據(jù)的問題
這篇文章主要介紹了探究在C++程序并發(fā)時保護共享數(shù)據(jù)的問題,也有利于大家更好地理解C++多線程的一些機制,需要的朋友可以參考下2015-07-07