VS Code Vue代码格式化

本文介绍了如何在Visual Studio Code (VS Code) 中配置Vue项目的代码格式化,包括设置Vue主题、使用vetur插件、启用js-beautify-html格式化器、调整模板验证、设置Prettier选项以及开启自动格式化等功能,以实现更高效和规范的Vue代码编辑体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

{
    // 工作区颜色主题(Vue Theme)

    "workbench.colorTheme": "Vue Theme",

    // 工作区图标主题(vscode-icons)

    "workbench.iconTheme": "vscode-icons",

    // vetur使用格式化插件:js-beautify-html

    "vetur.format.defaultFormatter.html": "js-beautify-html",
    // "vetur.format.defaultFormatter.js": "vscode-typescript",
    // 格式化插件格式配置
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned"
        }
    },

    // 模板格式检查

    "vetur.validation.template": false,

    // 单引号

    "prettier.singleQuote": true,

    // 去掉结尾分号

    "prettier.semi": false,

    // Tab宽度

    "prettier.tabWidth": 2,
    "editor.tabSize": 2,
    //让prettier使用eslint的代码格式进行校验
    // "prettier.eslintIntegration": true,
    // 函数名后面加空格(符合eslint标准)
    // "javascript.format.insertSpaceBeforeFunctionParenthesis": true,

    // 根据文件类型设置Tab宽度

    "editor.detectIndentation": false,

    // tab自动补全

    "emmet.triggerExpansionOnTab": true,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact",
        "plaintext": "jade"
    },

    // 编辑器字体大小

    "editor.fontSize": 16,

    // 终端字体大小

    "terminal.integrated.fontSize": 16,

    "git.autofetch": true,

    "explorer.confirmDelete": false,

    // 提示支持文件类型

    "emmet.syntaxProfiles": {
        "vue-html": "html",

        "vue": "html"
    },

    // 保存时自动格式化

    "editor.formatOnSave": true,

    "git.confirmSync": false
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值