How do I set the maximum line length in PyCharm?

断了今生、忘了曾经 提交于 2019-12-18 09:58:08

问题


I am using PyCharm on Windows and want to change the settings to limit the maximum line length to 79 characters, as opposed to the default limit of 120 characters.

Where can I change the maximum amount of characters per line in PyCharm?


回答1:


Here is screenshot of my Pycharm. Required settings is in following path: File -> Settings -> Editor -> Code Style -> General: Right margin (columns)




回答2:


For PyCharm 2018.1 on Mac:

Preferences (+,), then Editor -> Code Style:

For PyCharm 2018.3 on Windows:

File -> Settings (Ctrl+Alt+S), then Editor -> Code Style:

To follow PEP-8 set Hard wrap at to 80.




回答3:


For PyCharm 4

File >> Settings >> Editor >> Code Style: Right margin (columns)

suggestion: Take a look at other options in that tab, they're very helpful




回答4:


You can even set a separate right margin for HTML. Under the specified path:

File >> Settings >> Editor >> Code Style >> HTML >> Other Tab >> Right margin (columns)

This is very useful because generally HTML and JS may be usually long in one line than Python. :)




回答5:


For PyCharm 2017

We can follow below: File >> Settings >> Editor >> Code Style.

Then provide values for Hard Wrap & Visual Guides for wrapping while typing, tick the checkbox.

NB: look at other tabs as well, viz. Python, HTML, JSON etc.




回答6:


For anyone, or myself if I reload my machine, who this is not working for when you do a code reformat there is an additional option to check under editor->code style->python : ensure right margin is not exceeded. Once this was selected the reformat would work.



来源:https://stackoverflow.com/questions/17319422/how-do-i-set-the-maximum-line-length-in-pycharm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!