IntelliJ IDEA 2016.3 Help

Splitting String Literals on Newline Symbols

You can split a string literal on newline symbols (\n) by using the Break string on '\n' intention action. That is, a string literal in a code fragment like this:

String s = "Hello,\nWorld!";

can be easily transformed into corresponding concatenation:

String s = "Hello,\n" + "World!";

To do that:

  1. Place the cursor within the literal of interest.
  2. Click the yellow light bulb icon /help/img/idea/2016.3/intentionBulb.png or press Alt+Enter, and select Break string on '\n'.
Last modified: 22 December 2016