如何在 Vim 的 Syntastic 中将 Python 最大允许行长度设置为 120?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28118565/
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 02:45:17  来源:igfitidea点击:

How can I set the Python max allowed line length to 120 in Syntastic for Vim?

pythonvimpylintpython-modesyntastic

提问by feoh

I'm using python-modefor Vim, I prefer for there to be 120 character lines rather than the stark 80 as defined in the PEP8 standard.

我正在为 Vim使用python 模式,我更喜欢有 120 个字符行,而不是 PEP8 标准中定义的 80 个字符行。

In python-mode, this is easy. I just add the following to my ~/.vimrc:

在python模式下,这很容易。我只是将以下内容添加到我的 ~/.vimrc 中:

" Pylint configuration file
let g:pymode_lint_config = '$HOME/.pylint.rc'
let g:pymode_options_max_line_length=120

This works great, but then, I also wanted to use the superb Syntasticplugin for checking syntax of various other kinds (Chef recipes for foodcritic, for example.)

这很好用,但是,我还想使用出色的Syntastic插件来检查各种其他类型的语法(例如,美食评论家的厨师食谱。)

Unfortunately, Syntastic also does Python linting, and as such it has now started complaining about my 120 character lines. Is there something similar I can do to it as well to make it stop complaining about my slightly longer lines?

不幸的是,Syntastic 也进行 Python linting,因此它现在开始抱怨我的 120 个字符行。有什么我可以做的类似的事情,让它不再抱怨我稍微长一点的线吗?

采纳答案by Fedalto

You can pass additional arguments to each linter. For pylint, you can use:

您可以向每个 linter 传递额外的参数。对于pylint,您可以使用:

let g:syntastic_python_pylint_post_args="--max-line-length=120"

回答by zkanda

This is now configured globally in ~/.config/flake8in linux and ~/.flakein windows. The file can look like this.

这现在~/.config/flake8在 linux 和~/.flakewindows 中全局配置。该文件可能如下所示。

[flake8]
max-line-length = 120

Have a look at their documentation for per project settings: http://flake8.readthedocs.io/en/latest/user/configuration.html#project-configuration

查看每个项目设置的文档:http: //flake8.readthedocs.io/en/latest/user/configuration.html#project-configuration

回答by Lerner Zhang

I would just recommend you disable the length checking by adding this line to your .vimrc dot file:

我只是建议您通过将此行添加到您的 .vimrc 点文件来禁用长度检查:

let g:pymode_lint_ignore = "E501,W"

回答by Venu Gopal Tewari

There is a file named - defaults.pyinside your virtual environment folder - ......./lib/python3.6/site-packages/flake8

虚拟环境文件夹中有一个名为 - defaults.py 的文件 - ......./lib/python3.6/site-packages/flake8

You can change the value of max-line-length in that file.

您可以更改该文件中 max-line-length 的值。