Embed Selection

Embeds the selection into the specified code block. The following code blocks are available:

Code Block Description
try..catch Embeds the selection into the try..catch code block, selects the whole generated block, and drops a marker onto the catch section.
try..finally Embeds the selection into the try..finally code block, selects the whole generated block, and drops a marker onto the finally section.
try..catch/finally Embeds the selection into the try..catch/finally code block, selects the whole generated block, and drops markers onto the catch and finally sections.
#region..#endregion Embeds the selection between the #region and #endregion directives and selects the created region name.
#if..#endif Embeds the selection between the #if and #endif directives and places the cursor after the #if directive.
while() Embeds the selection into the while() code block, places the cursor into the conditional statement brackets, and drops a marker onto the initial selection.
do..while() Embeds the selection into the do..while() code block, places the cursor into the conditional statement brackets, and drops a marker onto the initial selection.
using() Embeds the selection into the using() code block, places the cursor into the brackets, and drops a marker onto the initial selection.
lock() Embeds the selection into the lock() code block, places the cursor into the brackets, and drops a marker onto the initial selection.
block - { } Encloses the selection in braces and selects the whole generated block.
BeginUpdate..EndUpdate Embeds the selection between the BeginUpdate and EndUpdate method calls of an object from the clipboard and selects the whole generated block.
WaitCursor Embeds the selection into the try..finally block, provided that the WaitCursor will be used during the selected code lines' execution. Creates linked identifiers for references to the SaveCursor variable.
To string Quotes the selected code section and selects the whole generated block.
Comment box Embeds the selection into the comment box and selects the whole generated block.

Availability

From the context menus or via shortcuts:

  • when one or more code lines are selected.

Example

private string TestMethod(string FileName)
{TestMethod1()
    TestMethod2()
}
Private Sub TestMethod()TestMethod1()
    TestMethod2()
End Sub

Result:

private string TestMethod(string FileName)
{try
    {
        TestMethod1()
        TestMethod2()
    }
    catch (Exception ex)
    {

    }
}
Private Sub TestMethod()Try
        TestMethod1()
        TestMethod2()
    Catch ex As Exception

    End Try
End Sub