vscode中自定義代碼塊

  • 打開vscode>文件>首選項(xiàng)>用戶代碼片段>新建json文件
  • 或者按ctrl +shift + p 輸入 snippet 新建
{
    // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
    // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
    // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
    // Placeholders with the same ids are connected.
    // Example:
    "Print to console": {
        "scope": "javascript,typescript",
        "prefix": "log",
        "body": [
            "console.log('$1');",
            "$2"
        ],
        "description": "Log output to console"
    },
    "for of ": {
        "scope": "javascript,typescript",
        "prefix": "fof",
        "body": [
            "for(let item of $1){"
                    ,"\t$2"
            ,"}"
        ],
        "description": "快速循環(huán)數(shù)組"
    }
}
(注意:創(chuàng)建哪種語言的代碼片段就進(jìn)相應(yīng)語言的代碼片段區(qū)域,寫js代碼段就不要把代碼段寫在了php的代碼段編寫區(qū))

\r\n:代表換行,填寫幾個(gè)代表換幾行,
\t:tab數(shù),有幾個(gè)代表有幾個(gè)tab

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一.選擇合適的編輯器,提高編程效率 代碼編輯器的選擇,可以說是開發(fā)者社區(qū)中一個(gè)經(jīng)久不衰的話題,現(xiàn)今編輯器的數(shù)量數(shù)不...
    露餡的番茄閱讀 65,672評論 0 58
  • Download Visual Studio Code 簡介 VSCode是微軟推出的一款輕量編輯器,采取了和VS...
    jrg陳咪咪sunny閱讀 3,048評論 0 3
  • 《最后一天》·畢了業(yè)的時(shí)同學(xué) 就目前而言:數(shù)學(xué)作業(yè)已經(jīng)搞定,代數(shù)一科,重在理解,每天一題,毫無壓力;英語作業(yè)更加簡...
    子沵閱讀 323評論 2 1
  • 健康之七要素 第一,一定要吃好3頓飯; 第二,一定要睡好8個(gè)小時(shí)覺; 第三,每天堅(jiān)持運(yùn)動半個(gè)小時(shí); 第四,每天要笑...
    健緣閱讀 880評論 0 1

友情鏈接更多精彩內(nèi)容