This Refactoring divides a string into two parts at the caret position or three parts by extracting the selected text. This is helpful when you need to replace a part of a string with a variable.
Available when the caret is within a string literal or a part of a string is selected.
Place the caret into a string literal. You can also divide one string into three concatenated strings by selecting the part you need to separate.
The blinking cursor shows the caret's position at which the Refactoring is available.
- Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
- Select Split String from the menu.
After execution, the Refactoring splits the string into two or three concatenated strings.