ReSharper 2024.3 Help

Split and join string literals

When you type a long string literal, ReSharper 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,

ReSharper: Splitting string literals

pressing Enter will split the string correctly so that your code syntax does not get broken:

ReSharper: Splitting string literals

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 Environment | Editor | Behavior page of ReSharper options Alt+R, O.

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.

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is not available in Visual Basic

Feature is available in C++

Feature is not available in HTML

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is available in JavaScript

Feature is available in TypeScript

Feature is not available in CSS

Feature is not available in XML

Feature is not available in XAML

Feature is not available in Resource files

Feature is not available in build script files

Feature is not available in Protobuf

Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 25 September 2024