Split and join string literals
When you type a long string literal, JetBrains Rider helps you split the literal into multiple lines and add the necessary quotation marks and plus signs.
While the caret is within a string literal,
![JetBrains Rider: Splitting string literals JetBrains Rider: Splitting string literals](https://resources.jetbrains.com.cn/help/img/rider/2024.2/split_literal_1.png)
pressing Enter will split the string correctly so that your code syntax does not get broken:
![JetBrains Rider: Splitting string literals JetBrains Rider: Splitting string literals](https://resources.jetbrains.com.cn/help/img/rider/2024.2/split_literal_2.png)
By default, if you delete the +
sign between the concatenated parts of a string literal, the parts will be merged into a single literal and the redundant quotes will be removed. You can disable this behavior by clearing the Join concatenated strings when removing the plus sign between them checkbox on the page of JetBrains Rider settings Ctrl+Alt+S.
Another way of splitting a string literal is to place the caret where you want to split the string, press Alt+Enter and choose Split string. This context action will also add necessary quotation marks and +
, but both parts of the string will stay on the same line.