สร้างกำหนดเอง snippet vscode
/*To create or edit your own snippets, select User Snippets
under File > Preferences > User Snippets (Code > Preferences on macOS),
and then select the language for which the snippets should appear*/
// Snippets are written in JSON Example:
{
"Your Snippet Name": {
"prefix": "ysn",
"body": [
"//Here you type all the code that should appear",
"//Separating each line",
"//Remember to add tabs with \t"
]
}
}
กับชิ้นส่วนต่างๆของรหัส
// in file 'Code/User/snippets/javascript.json' for only JS files
{
"For Loop": {
"prefix": ["for", "for-const"],
"body": ["for (const ${2:element} of ${1:array}) {", "\t$0", "}"],
"description": "A for loop."
}
}
// in file 'Code/User/snippets/fileName.code-snippets' for Global Snippets
{
"For Loop": {
"scope": "javascript,typescript,php,html",
"prefix": ["for", "for-const"],
"body": ["for (const ${2:element} of ${1:array}) {", "\t$0", "}"],
"description": "A for loop."
}
}