简体   繁体   English

如何在PyCharm中自定义代码格式?

[英]How can I customize code formatting in PyCharm?

Is it possible to do arbitrary code formatting in PyCharm? 是否可以在PyCharm中进行任意代码格式化? I am trying to create separate lines for each parameter with a comma after the last parameter. 我试图为每个参数在最后一个参数后创建一个逗号分隔的行。 Eg 例如

def f(x, y):
    pass

to

def f(
    x,
    y,
):
    pass

I am also interested in a more general solution. 我也对更通用的解决方案感兴趣。 The closest I found is EditorConfig , but that is mostly for code spacing rules. 我找到的最接近的是EditorConfig ,但这主要用于代码间距规则。

This isn't achievable at the moment. 目前尚无法实现。 There are various feature requests about code formatting (like https://youtrack.jetbrains.com/issue/PY-22986 ), but feel free to submit another one for your needs. 有关代码格式的功能有多种要求(例如https://youtrack.jetbrains.com/issue/PY-22986 ),但是可以随时提交另一种功能来满足您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM