RubyMine 2017.1 Help

Simple, Parameterized and Surround Live Templates

On this page:

Simple live templates

Simple templates contain 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

Parameterized templates contain plain text and variables that enable user input.

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 RubyMine automatically.

When a parameterized live template is invoked and expanded in the Editor, RubyMine 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, RubyMine will suggest:

  • A name for the index variable (i, j, etc.).
  • 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.

Examples

Insert parameterized live template (Ctrl+J):

/help/img/idea/2017.1/rm_insert_parameterized_live_template.png

Surround with live template (Ctrl+Alt+J):

/help/img/idea/2017.1/html_surround_with_live_template.png

Refer also to the page Wrapping a Tag. Example of Applying Surround Live Templates.

Cucumber feature:

/help/img/idea/2017.1/ruby_featureLiveTemplate.png
Rails has_many relationship:
/help/img/idea/2017.1/ruby_liveTemplateHasMany.png

See Also

Last modified: 18 July 2017