abrookins/WrapToColumn

Support for strings (Python / Jinja2)

rustikus opened this issue · 2 comments

Thanks for the plugin. This is exactly what I was looking for.
But one feature is currently missing (or at least not working for me) if I use it for python files. If I have a long string and use "wrap to column", the string is not wrapped correctly (" or ' is missing).

This is what is happening for: 'test1 test2 test3 test4 test5 test6 test7 test8 test9'

AS-IS:
'test1 test2 test3 test4 test5
test6 test7 test8 test9'

TO-BE:
'test1 test2 test3 test4 test5'
'test6 test7 test8 test9'

Thanks again and regards!

Thank you! I'm glad you found the plugin useful. Languages handle wrapping string objects differently. WrapToColumn is intended for plaintext, not string objects, but fortunately the editor (Intellij IDEA/PyCharm/etc.) can generally reflow string objects (i.e. strings designated by quotation marks) correctly based on your code format preferences. Have you tried the Reformat Code action? That should break the string based on your current column preference, in a Python-specific way, e.g.:

    'test1 test2 test3 test4 test5 test6 test7 test8 test9' \
    'test3 test1 test2 test3'

Thanks for the hint. Unfortunately this is what I tried previously. For some reason this is not working in PyCharm for Python and Jinja2 templates. I think I need to contact JetBrains about this.
Thanks again!