Child pages
  • Live Templates
Skip to end of metadata
Go to start of metadata

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:

  1. Press Ctrl+Alt+S to open the Settings Dialog,
  2. Click Live Templates and then expand Scala in the Live Templates tree,
  3. 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.

Icon

You can bind the most frequently used Live Templates to a keyboard shortcut via Keymap in the same Settings Dialog.

  • No labels

1 Comment

  1. 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.