Python Visual Studio 代码禁用自动换行长行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47406741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:11:58  来源:igfitidea点击:

visual studio code disable auto wrap long line

pythonvisual-studio-codepylint

提问by Kymo Wang

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.

我使用 vs code 用 pylint 编写 python。当我按ctrl+ S(保存)时,编辑器将一个长行包装成多个短行。如何禁用该操作或将换行列数配置为 120(默认为 80)?我试过"python.linting.pylintArgs": ["--max-line-length=120"]"editor.wordWrapColumn": 120,但没有奏效。

回答by Chayapol

Check your Python formatting provider.

检查您的 Python 格式提供程序。

"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-lengthfor autopep8instead.

我猜你的情况是不pylint的谁一直缠绕长长的队伍,但是autopep8。尝试设置--max-line-lengthautopep8代替。

"python.formatting.autopep8Args": [
    "--max-line-length=200"
]

回答by Meetai.com

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:

使用自定义参数时,命令行上由空格分隔的参数字符串的每个顶级元素必须是 args 列表中的一个单独项目。例如:

"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"]

"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 settingshere: https://code.visualstudio.com/docs/python/editing#_formatterspecific-settings

要正确格式化这些 Python 设置,您可以在此处检查 特定于格式化程序的设置https: //code.visualstudio.com/docs/python/editing#_formatterspecific-settings

Also check the answers here: https://stackoverflow.com/a/54031007/1130803

还要检查这里的答案:https: //stackoverflow.com/a/54031007/1130803