Is it possible to set Align key-value pair in Pycharm Code Style? I'm looking for something that will reformat:
nickname = models.CharField(unique=True, max_length=24)
biography = models.TextField(default=BIO_DEFAULT_STRING)
avatar = models.ImageField(upload_to='members/avatars/')
to:
nickname = models.CharField(unique=True, max_length=24)
biography = models.TextField(default=BIO_DEFAULT_STRING)
avatar = models.ImageField(upload_to='members/avatars/')
I got it working in PhpStorm, can't find it in PyCharm.
You need a function from plugin String Manipulation:
Menu
→ Code
→ Align to Columns
Settings
→ Keymap
Add Keyboard Shortcut
(Enter)Apply
and Ok
It is really strange, but PyCharm 2016 has this stuff, and i was to search the way to turn it OFF. I found this question, while searching "How to turn align by value".
There you need Other tab, where you'll find Dict Aligment settings. There is 3 types:
Here is a screenshot
Have no idea why they added that stuff, maybe because of platform unification, but it is exist and was turned to 'Align on value'
by default for me after i've updeted PyCharm to 2016.2.
A litle bit more explanations:
It was asked how to make aligns in PyCharm code formating, for example in dicts.:
Here how does dict should looks like via PEP:
i_am_a_dict = {
key:value,
another_key:another_value,
a_very_long_key:one_more_value
}
That's how does it looks for me in PyCharm after platform update (and such format DO NOT match PEP, but it can be done by PyCharm settings:
i_am_a_dict = {
key: value,
another_key: another_value,
a_very_long_key:one_more_value
}
It was aligned by values. And the question was about "How to align key:values in PyCharm"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With