visual studio code disable auto wrap long line

2020-05-14 04:57发布

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.

2条回答
成全新的幸福
2楼-- · 2020-05-14 05:25

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

查看更多
我命由我不由天
3楼-- · 2020-05-14 05:34

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"
]
查看更多
登录 后发表回答