【发布时间】:2013-06-23 13:17:40
【问题描述】:
我在 Windows 上使用 PyCharm,并希望更改设置以将最大行长度限制为 79 字符,而不是默认限制 120 字符。
我在哪里可以更改 PyCharm 中每行的最大字符数?
【问题讨论】:
我在 Windows 上使用 PyCharm,并希望更改设置以将最大行长度限制为 79 字符,而不是默认限制 120 字符。
我在哪里可以更改 PyCharm 中每行的最大字符数?
【问题讨论】:
【讨论】:
A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is most important. But most importantly: know when to be inconsistent -- sometimes the style guide just doesn't apply.
One big exception to PEP 8 is our preference of longer line lengths. We’re well into the 21st Century, and we have high-resolution computer screens that can fit way more than 79 characters on a screen. Don’t limit lines of code to 79 characters if it means the code looks significantly uglier or is harder to read.
对于 PyCharm 4
文件>>设置>>编辑器>>代码样式:右边距(列)
建议:看看该标签中的其他选项,它们非常有帮助
【讨论】:
您甚至可以为 HTML 设置单独的右边距。指定路径下:
文件 >> 设置 >> 编辑器 >> 代码样式 >> HTML >> 其他选项卡 >> 右边距(列)
这非常有用,因为通常 HTML 和 JS 在一行中通常比 Python 长。 :)
【讨论】:
对于任何人,或者我自己,如果我重新加载我的机器,当你重新格式化代码时这对谁不起作用,有一个额外的选项可以在 editor->code style->python 下检查:确保不超过右边距。选择此选项后,重新格式化将起作用。
【讨论】:
对于 PyCharm 2017
我们可以按照以下方式进行: 文件 >> 设置 >> 编辑器 >> 代码样式。
然后为Hard Wrap 和Visual Guides 提供值
for wrapping 输入时,勾选复选框。
注意:也请查看其他选项卡,即。 Python、HTML、JSON 等
【讨论】: