ReSharper Help

Predefined Live Templates for JavaScript

ReSharper | Templates Explorer | Live Templates | JavaScript

This topic lists all predefined live templates for JavaScript in ReSharper 9.2. For more information about live templates, see Creating Source Code Using Live Templates

TemplateDetails

Scope everywhere

Body

    ctx

    Current file context

    Scope everywhere

    Body

    $CTX$

    Parameters

    • CTX - Provides list of items describing current context. This includes file name, containing type name, namespace name, etc. (context)
    nguid

    Insert new GUID

    Scope everywhere

    Body

    $GUID$

    Parameters

    • GUID - Generates new Globally Unique Identifier (GUID) (guid)
    do (Imported JScript Snippets)

    Code snippet for do...while loop

    Scope JS statements

    Body

    do { $END$ } while($COND$)

    Parameters

    • COND - no macro
    • END - The caret position after the template is applied.
    dw (Imported JScript Snippets)

    Code snippet for a writeln function call

    Scope JS statements

    Body

    document.writeln($END$);

    Parameters

    • END - The caret position after the template is applied.
    else (Imported JScript Snippets)

    Code snippet for an else statement

    Scope JS statements

    Body

    else { $END$ }

    Parameters

    • END - The caret position after the template is applied.
    for (Imported JScript Snippets)

    Code snippet for a for loop

    Scope JS statements (up to ES 5, not in TS)

    Body

    for (var $VAR$ = 0; $VAR$ < $LENGTH$; $VAR$++){ $END$ }

    Parameters

    • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
    • LENGTH - no macro
    • END - The caret position after the template is applied.
    for (Imported JScript Snippets)

    Code snippet for a for loop

    Scope JS statements (ES 6)

    Body

    for ($VARKIND$ $VAR$ = 0; $VAR$ < $LENGTH$; $VAR$++){ $END$ }

    Parameters

    • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
    • LENGTH - no macro
    • VARKIND - Displays the specified list of values. (list)
    • END - The caret position after the template is applied.
    forin (Imported JScript Snippets)

    Code snippet for a for...in loop

    Scope JS statements (up to ES 5, not in TS)

    Body

    for (var $VAR$ in $ARRAY$){ $END$ }

    Parameters

    • ARRAY - no macro
    • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
    • END - The caret position after the template is applied.
    forin (Imported JScript Snippets)

    Code snippet for a for...in loop

    Scope JS statements (ES 6)

    Body

    for ($VARKIND$ $VAR$ in $ARRAY$){ $END$ }

    Parameters

    • ARRAY - no macro
    • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
    • VARKIND - Displays the specified list of values. (list)
    • END - The caret position after the template is applied.
    forr (Imported JScript Snippets)

    Code snippet for a reverse for loop

    Scope JS statements (up to ES 5, not in TS)

    Body

    for (var $VAR$=$LENGTH$-1;$VAR$ >=0; $VAR$--){ $END$ }

    Parameters

    • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
    • LENGTH - no macro
    • END - The caret position after the template is applied.
    forr (Imported JScript Snippets)

    Code snippet for a reverse for loop

    Scope JS statements (ES 6)

    Body

    for ($VARKIND$ $VAR$=$LENGTH$-1;$VAR$ >=0; $VAR$--){ $END$ }

    Parameters

    • VAR - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
    • LENGTH - no macro
    • VARKIND - Displays the specified list of values. (list)
    • END - The caret position after the template is applied.
    fun

    Create JavaScript function

    Scope JS expressions

    Body

    function($parameters$){ $END$ }

    Parameters

    • parameters - no macro
    • END - The caret position after the template is applied.

    Before expansion

    Reference__Options__Templates__Live_Templates__Predefined__JavaScript__fun__before

    After expansion
    Reference__Options__Templates__Live_Templates__Predefined__JavaScript__fun__after

    function (Imported JScript Snippets)

    Code snippet for a function

    Scope JS statements

    Body

    function $name$($parameters$){ $END$ }

    Parameters

    • name - no macro
    • parameters - no macro
    • END - The caret position after the template is applied.
    if (Imported JScript Snippets)

    Code snippet for an if statement

    Scope JS statements

    Body

    if ($COND$){ $END$ }

    Parameters

    • COND - no macro
    • END - The caret position after the template is applied.
    while (Imported JScript Snippets)

    Code snippet for a while loop

    Scope JS statements

    Body

    while ($COND$){ $END$ }

    Parameters

    • COND - no macro
    • END - The caret position after the template is applied.
    with (Imported JScript Snippets)

    Code snippet for a with statement

    Scope JS statements

    Body

    with ($EXPR$){ $END$ }

    Parameters

    • EXPR - no macro
    • END - The caret position after the template is applied.
    switch (Imported JScript Snippets)

    Code snippet for a switch statement

    Scope JS statements

    Body

    switch ($EXPR$){ case $CASE1$: $END$ default: }

    Parameters

    • EXPR - no macro
    • CASE1 - no macro
    • END - The caret position after the template is applied.
    try (Imported JScript Snippets)

    Code snippet for a try catch statement

    Scope JS statements

    Body

    try { $END$ } catch (e) { }

    Parameters

    • END - The caret position after the template is applied.
    itar

    Iterate an array

    Scope JS statements

    Body

    for (var $INDEX$=0;$INDEX$<$ARRAY$.length;$INDEX$++){ var $VAR$ = $ARRAY$[$INDEX$];$END$ }

    Parameters

    • ARRAY - no macro
    • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point. (suggestIndexVariable)
    • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
    • END - The caret position after the template is applied.

    Before expansion

    Reference__Options__Templates__Live_Templates__Predefined__JavaScript__itar__before

    After expansion
    Reference__Options__Templates__Live_Templates__Predefined__JavaScript__itar__after

    generator (Imported JScript Snippets)

    Code snippet for a generator

    Scope JS statements (ES 6, not in TS)

    Body

    function *$name$($parameters$){ $END$ }

    Parameters

    • name - no macro
    • parameters - no macro
    • END - The caret position after the template is applied.
    forof (Imported JScript Snippets)

    Code snippet for a for-of loop

    Scope JS statements (ES 6)

    Body

    for ($VARKIND$ $VAR$ of $ARRAY$){ $END$ }

    Parameters

    • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable. (suggestVariableName)
    • ARRAY - no macro
    • VARKIND - Displays the specified list of values. (list)
    • END - The caret position after the template is applied.
    Last modified: 21 September 2015