I use vs code to write python with pylint. When I press ctrl
+S
(save), the editor wrap a long line into multiple short lines. How to disable the action or configure wrap column count to 120 (default is 80)? I have tried "python.linting.pylintArgs": ["--max-line-length=120"]
and "editor.wordWrapColumn": 120
, but didn't work.
问题:
回答1:
Check your Python formatting provider.
"python.formatting.provider": "autopep8"
I guess in your case it is not PyLint who keeps wrapping the long lines, but autopep8
.Try setting --max-line-length
for autopep8
instead.
"python.formatting.autopep8Args": [
"--max-line-length=200"
]
回答2:
When using custom arguments, each top-level element of an argument string that's separated by space on the command line must be a separate item in the args list. For example:
"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"], "python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"], "python.formatting.blackArgs": ["--line-length", "100"]
For proper formatting of these Python settings you can check Formatter-specific settings here: https://code.visualstudio.com/docs/python/editing#_formatterspecific-settings
Also check the answers here: https://stackoverflow.com/a/54031007/1130803