How to split long strings in IntelliJ IDEA automatically?

You can use auto-formatting by running the Reformat code function
(CTRL+ALT+L) after few changes in Code Style settings.

(alternatively Reformat code, ++L on MacOS),

  • Press CTRL+ALT+S to open Settings window (or Preferences, +, on MacOS)
  • Go to Code Style menu, and choose Java submenu
  • Go to Wrapping and Braces tab
  • 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 / MacOS ++L) long strings exceeding line character limit will be automatically cut into multiple lines.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)