vscode手册

这里记录 vscode 的配置和技巧

因为安装了 Prettier 保存时自动格式化代码.

不格式化保存: F1=>format=>不格式化保存

.vscode 文件夹创建文件 vue3.code-snippets

json

{
    "Vue模板": {
        "scope": "vue",
        "prefix": "vvv",
        "body": [
            "<template>",
            "\t<div>",
            "\t\tdata",
            "\t</div>",
            "</template>\n",
            "<script setup lang='ts'>",
            "defineOptions({",
            "\tname: '$1'",
            "})",
            "</script>\n",
            "<style scoped>\n",
            "</style>"
        ],
        "description": "Vue模板"
    }
}
  • 当你输入 vvv, 就会自动出现模板
  • 默认光标会出现在 $1 的位置, 你可以继续添加 $2
  • 填写完 $1 后使用 tab 键, 会跳转到 $2

json

{
    "[typescript]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": "always"
        }
    },
    "editor.defaultFormatter": "oxc.oxc-vscode",
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "explorer.confirmDelete": false,
    "files.associations": {
        "*.json": "jsonc"
    },
    "files.autoSave": "afterDelay",
    "git.autofetch": true,
    "git.confirmSync": false,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "liveServer.settings.donotShowInfoMsg": true,
    "oxc.fmt.experimental": true,
    "python.venvPath": ".venv",
    "typescript.updateImportsOnFileMove.enabled": "always"
}