IntelliJ IDEA 12.1.0 Web Help

11.1+

The Surround with feature allows you easily put expressions or statements within blocks or language constructs. This feature in IntelliJ IDEA applies to:

ContextSurround withExample
Java statements
  • if
  • if/else
  • while
  • do/while
  • for
  • try/catch
  • try/finally
  • try/catch/finally
  • synchronized
  • Runnable
  • {}

wrapWithStatement.png

Java expressions
  • (expr)
  • ((Type)expr)
  • !(expr instanseof Type)
wrapExpression.png
XML/HTML /JSP/JSPX tags wrapTags.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
ActionScript statements
  • if
  • if / else
  • while
  • do / while
  • for
  • try / catch
  • try / finally
  • try / catch / finally
  • with
  • function
  • {}
  • function expression
surround_with_action_script.png
PHP statements
  • if
  • if / else
  • while
  • do / while
  • for
  • foreach
  • try / catch
  • function
surround_with_php_statements.png
Custom folding region commentsAny fragment of code, where Surround With is applicablecustomFolding1
To surround a block of code
  1. Select the desired code fragment.
  2. On the main menu, choose Code | Surround With, or press Ctrl+Alt+TCtrl+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, or a shortcut key displayed next to each element of the list.

See Also

Concepts:

Procedures:

Reference:

Web Resources: