Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Collapse]CodeRush Classic
  What's New
 [Expand]System Requirements
 [Collapse]Concepts
  [Expand]Code Analysis
  [Expand]Code Style
   Feature Advisor
   FrictionFree Mode
   Mastering CodeRush Features
  [Expand]Visualization Tools
  [Expand]Navigation
  [Expand]Advanced Selection Tools
  [Expand]Clipboard Tools
  [Collapse]Coding Assistance
   [Expand]Code Providers
   [Expand]Code Templates
   [Expand]Refactorings
    AutoDeclare
    Automatic Declaration
    Comment/Uncomment
    Cycle Scope Up/Down
    Duplicate Line
    Embedding
    Intellassist
    IntelliRush
    Inversions
    Smart Constructor
    Smart Enter
    Smart Parens and Brackets
    Smart Paste
   Unit Test Runner
 [Expand]Visual Elements
 [Expand]Tool Windows
 [Expand]CodeRush Options
 [Expand]Examples
  Get More Help
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Embedding

CodeRush 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.

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.

How would you rate this topic?​​​​​​​