How to split long strings in IntelliJ IDEA automatically?

后端 未结 4 1678
迷失自我
迷失自我 2021-02-05 00:54

I am writing a test with very long strings, and I need to split those strings:

private static final String TOO_LONG_JSON = \"{field1:field1, field2:field2 ... fi         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 01:53

    You can use auto-formatting (CTRL + ALT + L), after few changes in Code Style settings.

    • Press CTRL + ALT + S to open Settings window
    • Find Code Style / Java section
    • Make sure to uncheck "Line Breaks" option and check "Ensure right margin is not exceeded" option
    • Press OK to accept changes you've made

    Now when using auto-formatting (CTRL + ALT + L) long strings exceeding line character limit will be automatically cut into multiple lines.

提交回复
热议问题