Simple Live Templates
A Simple template contains some fixed code that expands into plain text. When invoked and expanded in the editor, the code specified in the template is automatically inserted into your source code, replacing the abbreviation.
Parameterized Live Templates
A Parameterized template contains plain text and variables that enable user input.
If you need a dollar sign ($) in the template text, escape it by duplicating this character ($$).
After a template is expanded, variables appear in the editor as input fields whose values can be either filled in by the user or calculated by IntelliJ IDEA automatically.
When a parameterized live template is invoked and expanded in the Editor, IntelliJ IDEA can suggest some predefined values at the input positions of the variables. For example, if a parameterized template contains code for an iteration, then, on expanding the template, IntelliJ IDEA will suggest:
- A name for the index variable (i, j, etc.).
- A list of all suitable variables in the current scope (e.g. Arrays) as an expression for the iterated container.
- A name for the assigned variable that holds the current container element.
- Type of the elements in the iterated container.
Surround Live Templates
Surround templates work only with blocks of selected text. Such templates place code before and after the selected block.
Insert parameterized live template (Ctrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+Shift+Alt+JCommand JCommand JCommand J):
Refer also to the page Iterating Over an Array. Example of Applying Parameterized Live Templates.
Surround with live template (Ctrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JCtrl+Alt+JAlt Command JAlt Command JAlt Command J):
Refer also to the page Wrapping a Tag. Example of Applying Surround Live Templates.