...
IntellijIDEA lets you insert a gap with concatenation intention. To do that, in your editor enter a string and press
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
. The list of appropriate intentions opens.
...
Select Insert gap with concatenation ("+ +") and press
span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
.
Now you can insert a value into your string. You can evaluate the result in the Scala Console window.
...
For the Scala version 2.10 and later you have the ability to convert a string concatenation into the interpolated string.
To do that, select a value with concatenation in your string and press
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
. The list of appropriate intentions opens.
Select
Convert to interpolated string, press
span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
and view the result.
You can also choose an option Convert to formatted string and get your basic Java formatted string.
...
You can convert your string into a multi-line string. Simply enter your string, press
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
and select
Convert to """string""" option in the drop-down list of intentions.
...
You also can convert the multi-line string into the regular string.
Press
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
to open the drop-down list of intentions. Select
Convert to "string" and press
span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
.
View the result.
To start entering a multi-line string, simply type triple quotes in your editor.

If you press
span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
, it will automatically envoke
stripMargin method. The
stripMargin method removes the left-hand part of a multi-line string up to a specified delimiter.
...
The .replace("\r"," ") intention lets you keep the caret in 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
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
and select the appropriate intention from the drop-down list.
...
You can inject language or a reference into your multi-line string literals.
Enter a multi-line string, press
+ span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+ Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
and select
Inject Language/Reference intention from the drop-down list.
The list of available languages opens. Choose the appropriate one and press
span |
---|
|
Enter Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
.
To cancel the language injection, simply choose the Un-Inject Language/Reference intention.
...
You can set a different format for multi-line strings' options such as Margin char indent or Margin Char. You can also disable a multi-line strings support.
To open the Multi-line strings settings, in the main menu select
→ → → → span |
---|
|
Scala Wiki Markup |
---|
{span:class=shortcut}File{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Setting{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Project Settings{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Code Style{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Scala{span} |
. On the
Scala page select the
Multi-line strings tab.