Reformat string to match specified line length
Answered
Hi,
We decided to set the line length of our IDE (IntelliJ) to 200.
However, when trying to automatically reformat the code, it is not reformating strings that "broke" into a new line to match the new line length.
For example, I want this:
assert retrieve.data["accounts"][0]["balance"] == 0, "could not find the right balance" \
f"expected - 0, retrieved - {retrieve.data['accounts'][0]['balance']}"
To turn to this (after reformat):
assert retrieve.data["accounts"][0]["balance"] == 0, f"could not find the right balance expected - 0, retrieved - {retrieve.data['accounts'][0]['balance']}"
Thanks
Please sign in to leave a comment.
Hi - you need to disable the following option under File | Settings | Editor | Code Style | Java > Wrapping and Braces:
@...
Great, thanks! However, I want the auto-format to be applied only on strings and not dictionaries (for example).
Is that an option?
Thanks!
Not at the moment I believe. Feel free to submit a new feature request about it to our issue tracking system.
As a workaround, you can select chunks of code and perform Ctrl+Alt+L on them explicitly if you want to keep other parts of code from being formatted.