Skip to main content

Selection Embedding

  • 2 minutes to read

The Selection Embedding feature allows you to surround a selected code block with a boilerplate block (for example, try..catch). CodeRush includes predefined embeddings for C#, Visual Basic, and XAML.

Follow the steps below to embed one or more lines of code:

  1. Select code and press Ctrl+. or Ctrl+~ to invoke the Code Actions menu. You can use the Ctrl+W shortcut to select code and increase code selection.

  2. Open the Embed Selection group and choose a desired embedding from the list.

The following screencast shows how to wrap a selected code in the try..catch block:


Enable One-Key Selection Embedding Shortcuts

CodeRush allows you to run the Selection Embed commands with one-key shortcuts. For example, you can press C to wrap the selection in the try/catch code block, as shown in the screencast below:


Do one of the following to enable one-key embedding shortcuts:

Use the Setup Wizard

  1. Choose the CodeRush | Setup Wizard… menu item to invoke this wizard.
  2. Refer to the “One-key Selection Embedding” page, and check the “Enable one-key Embedding shortcuts” option. This option allows you to enable B, C, F, and T shortcuts.


Use the Shortcuts Options Page

Refer to the Selection | Embedding group in the Shortcuts options page, and enable the desired shortcut.


Customize Selection Embeddings

You can configure the Selection Embedding feature in the Editor | All Languages | Selection Embeddings options page.

Embeddings Page

For more information about this page, see the following topic: Selection Embedding Settings

See Also