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