Live Template is a piece of code that resembles a commonly used construction and contains context-sensitive macros, which automatically adjusts it to the context where you are using it.
Typically, a Live Template is associated with a short abbreviation which you can type when editing the code and then use Tab to expand it into the complete block of code.
Currently, Scala plugin comes with four Live Templates:
- main — generates main() method for runnable applications
- itr — creates a for loop, using the closest defined collections as generators
- itry — creates a for loop, using the closest defined collections as generators and yield modifier
- opt — creates a pattern-matching expression with scala.Option[T] argument and two branches
- priv — creates an expression for debug print of values
Live Templates are fully customizable:
- Press Ctrl+Alt+S to open the Settings Dialog,
- Click Live Templates and then expand Scala in the Live Templates tree,
- Edit the template body, using predefined macros to create context-sensitive parts, or
change the abbreviation that is used to invoke a template from editor.
1 Comment
Anonymous
Sadly, live templates for Java and Scale may conflict if the same abbreviation is used. I wish, jetbrains would allow the use of equal template names for different programming languages.