IntelliJ IDEA 2017.2 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 intentionBulb or press Alt+Enter, and select Break string on '\n'.
Last modified: 29 November 2017