IntelliJ IDEA 2017.1 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/2017.1/intentionBulb.png or press Alt+Enter, and select Break string on '\n'.
/help/img/idea/2017.1/SplitStringLiteralOnNewlineSymbol.png
Last modified: 18 July 2017