RubyMine 2017.2 Help

Surrounding Blocks of Code with Language Constructs

Applicable contexts

The Surround with feature (Code | Surround with or Ctrl+Alt+T) lets you put expressions or statements within blocks or language constructs. This feature in RubyMine applies to:

ContextSurround withExample
Ruby statements
  • (...)
  • BEGIN{}
  • END{}
  • if...then...end
  • while...do...end
  • unless...then...end
  • begin...end
ruby_wrapStatement.png
XML/HTML /RHTML tags
  • Tag
  • CDATA section
  • <% ... %>
  • Emmet
ruby_wrapTag.png
JavaScript statements
  • (expr)
  • !(expr)
  • if
  • if / else
  • while
  • do / while
  • for
  • try / catch
  • try / finally
  • try / catch / finally
  • with
  • function
  • { }
  • function expression
surround_with_java_script.png
Custom folding region comments Any fragment of code, where Surround With is applicable
/help/img/idea/2017.2/customFolding1.png

Surrounding blocks of code

To surround a block of code

  1. Select the desired code fragment.
  2. Do one of the following:
    • On the main menu, choose Code | Surround With
    • Press Ctrl+Alt+T.

    A pop-up window displays the list of enclosing statements according to the context.

  3. Select the desired surround statement from the list. To do that, use the mouse cursor, up and down arrow keys, or a shortcut key displayed next to each element of the list.
Last modified: 26 October 2017

See Also