Answer a question

For JavaScript formatter works fine but not for Python. I have installed autopep8 but it seems that I can't set max line length. I tried this:

"python.formatting.autopep8Args": [
    "--max-line-length",
    "79",
    "--experimental"
  ]

and my settings.json looks like this:

{
  "workbench.colorTheme": "One Dark Pro",
  "git.autofetch": true,
  "workbench.iconTheme": "material-icon-theme",
  "git.enableSmartCommit": true,
  "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "javascript.updateImportsOnFileMove.enabled": "always",
  "[javascriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "liveServer.settings.donotShowInfoMsg": true,
  "editor.formatOnSave": true,
  "window.zoomLevel": 1,
  "vscode-w3cvalidation.validator-token": "Fri, 07 Aug 2020 07:35:05 GMT",
  "python.formatting.provider": "autopep8",
  "python.formatting.autopep8Args": [
    "--max-line-length",
    "79",
    "--experimental"
  ],
  "python.autoComplete.addBrackets": true,
  "python.autoComplete.extraPaths": []
}

Any ideas how to fix that?

Answers

From autopep8-usage, the default value of max-line-length is 79, so you can change to other value and have a try.

About the effect of autopep8 in vscode, I made a test with the same settings as yours, like the following screenshot shows:

enter image description here

every print sentence line-length is over 79, the first and the second print() parameters are expressions, and the setting works for the first one, not for the second. This is because setting applicable rules are provided by python extension and it has own caculation mechanism.

When it comes to print strings, the setting doesn't work, so if you mean this in your question, you can add the following code in user settings.json.

"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 79
Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐