RubyMine 6.3.0 Web Help

This section describes how to generate source code using live templates.

Using Live Templates enables you to create such code constructs as Ruby class or method, Rails render with action, an RSpec description, etc.

To explore the list of available live templates, in the IDE settings, open the Live Templates page.

To insert a live template in the source code
  1. Place the caret at the desired position, where the new construct should be added.
  2. Do one of the following:
    • On the main menu, choose Code | Insert Live Template.
    • Press Ctrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+Shift+Alt+JMeta+JCommand JCommand JCommand JCommand J.
    • Type some initial letters of the template abbreviation to get the matching abbreviations in the suggestion list. Note that the suggestion list may contain same abbreviations for different templates.
  3. From the suggestion list, select the desired template.

    Tip

    6.3+
    While the suggestion list is displayed, it is possible to view Quick Documentation for the items at caret, by pressing Ctrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+Q or Alt+Button2 ClickCtrl+QCtrl+Q or Alt+Button2 ClickAlt+Button2 Click, Ctrl+Shift+Space or F2Ctrl+Button2 Click or Ctrl+HF1, Control J or Control Button2 ClickControl J or Control Button2 ClickAlt Button2 Click or F2Control J or Control Button2 Click.

    rm_qdoc_live_template

  4. Press the template invocation key (this may be Space, TabTabTabTabTabTabTabTabTabTabTabTabTab or EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter, depending on the template definition). The new code construct is inserted in the specified position.
  5. If the selected template is parametrized and requires user input, the editor enters the template editing mode and displays the first input field highlighted with the red frame. Type your value in this frame and press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter or TabTabTabTabTabTabTabTabTabTabTabTabTab to complete input and pass to the next input field. After completing the last input field, the caret moves to the end of the construct, and the editor returns to the regular mode of operation.

Tip

It is also possible to type a template abbreviation, and then press Ctrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+JCtrl+Shift+Alt+JMeta+JCommand JCommand JCommand JCommand J.

See Also

Concepts:

Procedures:

Reference:

Web Resources: