前言
博主原來是使用 idea 的后來聽說 vscode 不錯,就上手試了試,這個界面真的愛了,
但是已經習慣了 idea 的快捷鍵和智能感知,今天抽時間配置了一下智能感知,
打開 json 檔案

快捷鍵:ctrl + shift + p
輸入:snippets
然后在這里輸入想要配置的語言,這里使用 JavaScript 作為示范

引數說明
prefix:快捷輸入的入口,body:快捷輸入的代碼體,輸入入口的字符后按回車自動呈現的代碼,字串間換行的話使用\r\n換行符隔開,如果有特殊字符需要進行轉義,多行代碼以 ,分隔,$0:游標最終的位置,$1 - $n:每次按下 tab 游標跳轉的位置,起始位置為$1,description:代碼段描述,智能感知時的描述,當定義的快捷輸入過多時的提示,
這里給出示例:
"Print to console": {
"prefix": "log",
"body": [
"console.log($1);"
],
"description": "Log output to console"
}
當我們敲入 log 時按回車代碼自動完成,效果如下:

下面為我的快捷鍵用來參考:
{
"function": {
"prefix": "fn",
"body": [
"function $1($2) {\r\n\t$3\r\n}"
],
"description": "function () {}"
},
"console.log": {
"prefix": "log",
"body": [
"console.log($1);"
],
"description": "console.log()"
},
"alert": {
"prefix": "al",
"body": [
"alert($1);"
],
"description": "alert()"
},
"class": {
"prefix": "cl",
"body": [
"$('.$1')"
],
"description": "class"
},
"id": {
"prefix": "id",
"body": [
"$('#$1')"
],
"description": "id"
},
"on": {
"prefix": "on",
"body": [
"on('click',function () {\r\n\t$1\r\n})"
],
"description": "on"
},
"for": {
"prefix": "fo",
"body": [
"for (var i = 0; i < $1; i++) {\r\n\t$2\r\n}"
],
"description": "for"
},
"if": {
"prefix": "ifif",
"body": [
"if ($1) {\r\n\t$2\r\n}"
],
"description": "if"
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/208236.html
標籤:其他
下一篇:檔案流、盒子模型、內邊距、外邊距、盒子模型水平方向的布局、盒子模型垂直方向的布局、盒子模型外邊距的折疊、行內元素的盒模型(萌新必看,大佬隨便)
