簡體   English   中英

如何在 VS Code 中禁用單行格式?

[英]How to disable one-line formatting in VS Code?

我的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,
  }

目前,當我保存 my.py 文件時,function 中的所有屬性將自動重新格式化為每行一個屬性。 如何禁用 function 中的屬性將跨越一定長度,並在需要時換行?

例如:

# 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'
)

好像您已經在 VS Code 中安裝了 Prettier - 代碼格式化程序,刪除擴展名並為 python 使用其他一些格式化程序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM