# String conversions

> **TL;DR**
> Required plugin: Scala: [how to install](get-started-with-scala.html#scala_plugin)

IntelliJ IDEA with the Scala plugin provides tools to help with string manipulations in Scala programming. This page highlights some of the most popular actions and shortcuts.

## Concatenation with + +

An idiomatic Scala way to include computation results in strings is to use interpolation.

If you need to split a string and concatenate it with an expression using the `+` operator, place the caret at the desired position within the string and invoke the intention actions menu by pressing `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)). Then select Insert gap with concatenation (" + + ").

IntelliJ IDEA splits the string and inserts the concatenation placeholders at the caret position.

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/scala_string_concatenation_with_plus.mp4)

## Triple-quote strings

If you want to include a quote character (`'"'`) in a regular string, you need to escape it by writing a backslash in front of the character (`'\"'`). It is tedious if you have many quote characters in the string, and it may also lead to typos that are difficult to spot. Instead, you can convert your regular string into a triple-quote one. To do that, enter your string, press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) and from the list of intentions, select Convert to """string""".

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/scala_triple_quote_string.mp4)

## Multi-line strings

With the same Convert to """string""" intention you can convert a regular string with escaped newline characters (`'\n'`) into a multi-line string. Press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) to open the list of intentions. Select Convert to "string" and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)). You can use the same intention once again to revert it.

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/scala_multi_line_strings.mp4)

To enter a multi-line string from scratch, type triple quotes in the editor. If you press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (NetBeans), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (Eclipse), `⏎` (Eclipse (macOS)), it will automatically invoke the `stripMargin` method. The `stripMargin` method removes the left part of a multi-line string up to a specified delimiter. The whitespaces are also preserved.

## Multi-line strings settings

Use the Multi-line strings tab in Scala settings to set a different format for multi-line string options such as Margin char indent or disable a multi-line strings support.

Procedure:

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Editor | Code Style | Scala`.

2. On the Scala page, select the Multi-line strings tab.

3. Edit the settings and click OK.

Use the Inject language or reference intention to insert a language or a reference into your multi-line string literals. For more information, refer to [Language Injections](using-language-injections.html).

[Video](https://resources.jetbrains.com/help/img/idea/2026.2/scala_language_injection.mp4)

## The 'replace '\r'' intention

This intention lets you keep the caret at the correct place on the next line in the multi-line strings regardless of what operating system you have at the moment. Enter a multi-line string, press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) and select the appropriate intention from the list.

![the replace intention](https://resources.jetbrains.com/help/img/idea/2026.2/add_replace_intention.png)

