Ctrl+Shift+P 输入“代码片段:配置用户代码片段”:

image

搜索你想要设置的语言代码片段,比如,我设置 .vue 文件的代码片段,选择 vue.json:

image

可以配置多个代码片段,一个片段通过一个 prefix 快速生成:

{
  "Vue3 snippet for TypeScript & Scss": {
    "prefix": "v3ts",
    "body": ["<script setup lang='ts'>\n", "</script>\n", "<template>\n", "</template>\n", "<style scoped lang='scss'>", "</style>"],
    "description": "Vue3 snippet"
  },
  "Vue3 snippet for JavaScript & Scss": {
    "prefix": "v3js",
    "body": ["<script setup lang='js'>\n", "</script>\n", "<template>\n", "</template>\n", "<style scoped lang='scss'>", "</style>"]
  },
  "Vue3 snippet for TypeScript & CSS": {
    "prefix": "v3t",
    "body": ["<script setup lang='ts'>\n", "</script>\n", "<template>\n", "</template>\n", "<style scoped lang='css'>", "</style>"],
    "description": "Vue3 snippet"
  },
  "Vue3 snippet for JavaScript & CSS": {
    "prefix": "v3j",
    "body": ["<script setup lang='js'>\n", "</script>\n", "<template>\n", "</template>\n", "<style scoped lang='css'>", "</style>"]
  }
}

上面定义了四个 prefix,在 .vue 文件中输入 prefix 快速生成代码片段:

image