RubyMine
 
2025.1
Get RubyMine

Live templates

Last modified: 26 February 2025

To expand a code snippet, type the corresponding template abbreviation and press Tab. Keep pressing Tab to jump from one variable in the template to the next one. Press ShiftTab to move to the previous variable.

Live templates (or code snippets) allow you to insert frequently-used constructions into your code. These can be conditions, blocks, loops, and so on. For example, the animation below shows how to quickly insert the if-else block by using the predefined ife abbreviation.

https://resources.jetbrains.com/help/img/idea/2025.1/rm_live_templates_example.png
Gif

RubyMine provides numerous predefined templates for various languages and frameworks, including Ruby, Rails, RSpec, JavaScript, and so on. If necessary, you can customize predefined templates or add new ones.

There are three types of live templates:

  • Simple templates contain only predefined code. When you expand a simple template, the text is automatically inserted into your source code, replacing the abbreviation.

  • Parameterized templates contain variables that enable user input. When you expand a parameterized template, you can replace variables manually or provide an expression to calculate them automatically.

  • Surround templates wrap a block of the selected code with the text specified by the user.