IntelliJ IDEA lets you use different Scala intention actions, convert your code from Java to Scala, and use different Scala templates while working in the IntelliJ IDEA editor.
Strings in Scala
You can add different intentions for strings, perform different actions, and set a different format for multi-line strings.
Check the following examples:
Use a Scala worksheet to quickly evaluate your results.
- Insert gap with concatenation ("+ +") into a string.
- Enter a string and press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎.
The list of appropriate intentions opens.

- Select Insert gap with concatenation ("+ +") and press ⏎⏎⏎⏎⏎.
Now you can insert a value into your string.

- Enter a string and press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎.
The list of appropriate intentions opens.
- Invoke the Convert to interpolated string intention.
- Convert a string into a multi-line string using the Convert to """string""" intention and vice versa.
- Enter your string, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ and from the drop-down list of intentions, select Convert to """string""".

- You also can convert the multi-line string into the regular string.
Press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ to open the drop-down list of intentions. Select Convert to "string" and press
⏎⏎⏎⏎⏎.
View the result.

Converting to multi-line strings removes escaped sequences such as '\\' or '\n'.
- To enter a multi-line string, simply type triple quotes in your editor.
If you press ⏎⏎⏎⏎⏎, it will automatically invoke the
stripMarginmethod. ThestripMarginmethod removes the left-hand part of a multi-line string up to a specified delimiter.
The white spaces are also preserved. Check the following example:

- Enter your string, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ and from the drop-down list of intentions, select Convert to """string""".
- Add the .replace("\r"," ") intention. This 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.
Simply enter a multi-line string, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ and select the appropriate intention from the drop-down list.

- Use the Inject Language/Reference intention to insert a language or a reference into your multi-line string literals.
- Enter a multi-line string, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ and from the drop-down list select
Inject Language/Reference.
The list of available languages and references opens.
- Choose the appropriate one and press ⏎⏎⏎⏎⏎.
To cancel the language injection, simply choose the Un-Inject Language/Reference intention.
- Enter a multi-line string, press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎ and from the drop-down list select
Inject Language/Reference.
- Use the Multi-line stings tab in Scala settings
to set a different format for multi-line strings' options such as
Margin charindent or disable a multi-line strings support.- In the main menu, select .
- On the Scala page, select the Multi-line strings tab.

- Edit the settings and click OK.
- Turn simple string into the interpolated one adding a variable reference.
Implicit conversions
IntelliJ IDEA lets you invoke implicit conversion methods and parameters:
- Implicit conversion methods
- Select an expression and press ⇧ ^ Q (^ Q for macOS) to
invoke the list of applicable implicit conversions.
The list shows the regular scope displayed on the top and the expanded scope that is displayed on the bottom of the list.
IntelliJ IDEA highlights an implicit conversion that was used for the selected expression. If IntelliJ IDEA cannot find the implicit conversion or if it finds more than one match then the list of Introduce Variable opens.

- You can make the implicit conversion method explicit. Press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎
and select Make explicit or Make explicit (Import method):

-
If you select Make explicit then IntelliJ IDEA returns a method call with the class name. It might be helpful if
you need to make sure that the compiler imports a particular implicit conversion method that you originally wanted:

-
If you select Make explicit (Import method) then the method is imported statically and IntelliJ IDEA returns just
its call without the class name. Also, the next time you open the list of useful implicit conversions you will see this method in the regular scope:

- Select an expression and press ⇧ ^ Q (^ Q for macOS) to
invoke the list of applicable implicit conversions.
The list shows the regular scope displayed on the top and the expanded scope that is displayed on the bottom of the list.
- Implicit parameters
- Place a cursor to the method where implicit conversion was used and press
⌃⇧P⌃⇧P⌃⇧P to invoke implicit parameters.
It might be helpful for code analyzing when you want to find out what implicit parameters were passed to the particular call.
IntelliJ IDEA also lets you view the recursive implicit parameters.
IntelliJ IDEA highlights the method call where implicit parameters were used.

- If IntelliJ IDEA cannot find method calls where implicit parameters were passed, it displays a pop-up message:

- Place a cursor to the method where implicit conversion was used and press
⌃⇧P⌃⇧P⌃⇧P to invoke implicit parameters.
It might be helpful for code analyzing when you want to find out what implicit parameters were passed to the particular call.
IntelliJ IDEA also lets you view the recursive implicit parameters.
Type Info action
IntelliJ IDEA lets you work with type inferences using the Scala Show Type Info action:
- To invoke the Show Type Info action in the editor, navigate to the value and press
⌥ Equals or ⌃⇧P⌃⇧P⌃⇧P⌥=⌥= (for Mac OS):

If you selected the Show type info on mouse hover after, ms checkbox on the Editor tab in , you can simply navigate with the mouse to a value to see its type information.
- You can also see the type information on a value definition. Simply put the caret on a value definition
and press ⌥ Equals or ⌃⇧P⌃⇧P⌃⇧P⌥=⌥= (for Mac OS):

You can use the same shortcuts to see the type information on expressions.
- To add a type annotation, highlight the value,
press ⌘I⌥⏎⌘I⌥⏎⌥⏎ and from the context menu select Add type annotation to value definition:
As a result, the type annotation is added:
To remove the type annotation, press ⌘I⌥⏎⌘I⌥⏎⌥⏎ and select Remove type annotation from value definition.
- You can also use the Adjust types action to shorten types with full qualified names.
Select the code in question, press ⌘I⌥⏎⌘I⌥⏎⌥⏎ and from the context menu, select Adjust types.
In this case the necessary imports are added.

Create from usage
IntelliJ IDEA lets you create new code elements without declaring them first:
- In the editor, type a name of a new code element and press ⌥⏎⌥⏎⌘1⌥⏎⌥⏎.
- From the list of intentions, select the one you need.
Press ⏎⏎⏎⏎⏎.
Structure view
IntelliJ IDEA lets you view a structure of your code:
- To open the Structure tool window, press ⌘7⌘7⌘7⌥7⌥7.

- To navigate from the Structure tool window to the code item in the editor,
press ⌘↓F4F3F4F4.
To simply highlight the code, press ⌘⏎⌘⏎⌘⏎⌃⏎⌃⏎.
Java-to-Scala code conversion
IntelliJ IDEA lets you convert Java code into Scala:
- Copy your Java code (expression, method, class) and paste it into a Scala file.

- IntelliJ IDEA displays the Convert the code from Java dialog suggesting a conversion.
Click OK.

If you do not want to use the copy/paste actions, you can open your Java file in the editor and select or press ^ ⇧ G.
In this case IntelliJ IDEA will create a Scala file with the converted code.
Scala templates
IntelliJ IDEA lets you use predefined Scala templates:
- In the editor start entering your code, press ⌘J⌘J⌃J⌃J.
IntelliJ IDEA displays the list of available Live templates for Scala.
- Select the one you need and press ⏎⏎⏎⏎⏎.
You can also define a new template or edit the existing one:
- Select .
- From options on the right, open the list of Scala templates.

- If you want to add a new template, click
.
If you want to edit the existing template, select the one you need and change the default definitions.

