【问题标题】:How to disable one-line formatting in VS Code?如何在 VS Code 中禁用单行格式?
【发布时间】:2021-02-18 14:44:44
【问题描述】:

我的settings.json 文件是:

{
    "python.pythonPath": "E:\\001_Kai_Duplicate\\Venv\\DesktopKubiK_Python37_TimeSeriesForecast\\python.exe",
    "python.pipenvPath": "<your-env-path>",   // if using pipenv
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "python.formatting.provider": "black",
    "python.formatting.autopep8Path": "<your-env-path>/bin/autopep8",
    "python.formatting.autopep8Args": [
      "--max-line-length",
      "70",
      "--aggressive",
    ],
    "python.linting.lintOnSave": true,
    "python.linting.enabled": true,
    // if using pylint
    "python.linting.pylintEnabled": false,
    "python.linting.pylintPath": "<your-env-path>/bin/pylint",
    "python.linting.pylintArgs": [
      "--load-plugins",
      "pylint_django", // only if you are using django framework
      "--enable=W0614",
      "--enable= W0611"
    ],
    // if using flake8 (uncomment below lines and comment above block of settings of pylint
    // "python.linting.pylintEnabled": false,
    // "python.linting.flake8Enabled": true,
    // "python.linting.flake8Path": "<your-env-path>/bin/flake8",
    // "python.linting.flake8Args": [
    //   "--max-line-length=130"
    // ],
    // to enable sort imports on save
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
    // to add environment vars while opening a new vscode terminal (name:val)
    "terminal.integrated.env.linux": {
      "DJANGO_ENV": "DEV"
    },
    "[python]": {
      "editor.tabSize": 4
    },
    "python.linting.pylamaEnabled": true,
    "prettier.printWidth": 80,
  }

目前,当我保存 .py 文件时,函数中的所有属性都会自动重新格式化为每行一个属性。如何禁用该功能,以便函数中的属性跨越一定长度,并在需要时换行?

例如:

# This format
some_func(param1 = 'A', param2 = 'B', param3 = 'C',
          param4 = 'D')

# Not this format
some_func(
    param1 = 'A', 
    param2 = 'B', 
    param3 = 'C',      
    param4 = 'D'
)

【问题讨论】:

    标签: python-3.x visual-studio-code vscode-settings


    【解决方案1】:

    好像你已经在 VS Code 中安装了 Prettier - 代码格式化程序,删除扩展并使用其他一些 python 格式化程序。

    【讨论】:

      猜你喜欢
      • 2020-11-03
      • 2021-04-21
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 2016-12-14
      • 2021-12-05
      • 2021-03-14
      相关资源
      最近更新 更多