【问题标题】:No space before opening parenthesis on auto format in VS Code在 VS Code 中打开自动格式的括号之前没有空格
【发布时间】:2016-10-17 12:56:11
【问题描述】:

如果我按 Shift + Alt + F 让 VS Code 格式化它转换的我的 JS 源代码

for(var key in indexObj)

for (var key in indexObj)

如何防止 VS Code 这样做?

【问题讨论】:

    标签: javascript visual-studio-code js-beautify


    【解决方案1】:
    • 安装beautify plugin for VSCode
    • 创建一个.jsbeautifyrc 文件。以this one为例
    • 将其space_before_conditional 值设置为false
    • 将文件放在您的主目录中以全局使用,或将其放在与您要格式化的 .js 所在的文件夹相同的文件夹中
    • Shift+Alt+F 以格式化您的代码

    【讨论】:

    【解决方案2】:

    要在没有插件的情况下解决此问题,您可以在 vscode settings.json 上设置配置:

    {
      "editor.formatOnSave": false,
      "editor.formatOnType": false
    }
    

    或转到 File - Preferences - Settings ,寻找 Format On Save 并取消选中它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-30
      • 2016-10-11
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 2019-04-13
      • 2020-07-21
      相关资源
      最近更新 更多