Skip to main content

Embedding

  • 3 minutes to read

CodeRush Classic enables you to quickly embed a selected code section into an appropriate block. You can use the Embed Selection code provider as well as the appropriate shortcut to apply a certain embedding.

Embedding

The following embeddings are available.

Embedding Shortcut Description
try..catch C Embeds a selection into the try..catch code block, selects the whole generated block, and drops a marker onto the catch section.
try..finally F Embeds a selection into the try..finally code block, selects the whole generated block, and drops a marker onto the finally section.
try..catch/finally T Embeds a selection into the try..catch/finally code block, selects the whole generated block, and drops markers onto the catch and finally sections.
#region..#endregion CTRL+3 Embeds a selection between the #region and #endregion directives, and selects the created region name.
#if..#endif Can be accessed only from the Embed Selection code provider. Embeds a selection between the #if and #endif directives, and places the cursor after the #if directive.
while() Can be accessed only from the Embed Selection code provider. Embeds a selection into the while() code block, places the cursor into the conditional statement brackets, and drops a marker onto the initial selection.
do..while() Can be accessed only from the Embed Selection code provider. Embeds a selection into the do..while() code block, places the cursor into conditional statement brackets, and drops a marker onto the initial selection.
using() U Embeds a selection into the using() code block, places the cursor into brackets, and drops a marker onto the initial selection.
lock() L Embeds a selection into the lock() code block, places the cursor into brackets, and drops a marker onto the initial selection.
block - { } B, SHIFT+[ Encloses a selection in braces and selects the whole generated block.
BeginUpdate..EndUpdate Can be accessed only from the Embed Selection code provider. Embeds a selection between the BeginUpdate and EndUpdate method calls of an object from the clipboard, and selects the whole generated block.
WaitCursor W Embeds a 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.
Stop Watch none Creates a new instance of the System.Diagnostics.Stopwatch class, embeds a selection into the try..finally block between the Stopwatch.Start() and Stopwatch.Stop() method calls, and outputs the Stopwatch.Elapsed value to the console.
To string SHIFT+’ Quotes a selected code section and selects the whole generated block.
Comment box Can be accessed only from the Embed Selection code provider. Embeds a selection into the comment box and selects the whole generated block.
Parentheses SHIFT+9, SHIFT+0. Can be accessed only via shortcuts. Embeds the selection into parentheses.
Not Parentheses SHIFT+1. Can be accessed only via a shortcut. Embeds the selection into the parentheses and places the logical Not (! in C#/C++, Not in VB) before the parentheses.

Note

All embeddings but the last two, are only available for a multi-line selection. The Parentheses and Not Parentheses embeddings are available for any selection.

You can customize existing embeddings and create new embeddings via the Embedding options page. To assign a shortcut to an embedding, use the Shortcuts options page.