Back to Devexpress

Parentheses

coderushforroslyn-403095-coding-assistance-selection-tools-selection-embedding-parentheses.md

latest2.7 KB
Original Source

Parentheses

  • May 05, 2021
  • 2 minutes to read

CodeRush allows you to embed a selected code into parentheses.

The following shortcuts are available:

  • Shift + 0 - embeds the selection into parentheses and places the caret after the close parenthesis.

  • Shift + 9 - embeds the selection into parentheses and places the caret before the open parenthesis.

  • Shift + 1 - embeds the selection into parentheses and places the logical Not (!) operator before the parentheses.

These shortcuts are initially disabled, do the following to enable them:

  1. Choose the CodeRush | Shortcuts… menu item to open the Shortcuts options page.

  2. Refer to the Selection | Embedding group in the shortcuts page, and enable Shift + 0 , Shift + 9 , and Shift + 1 shortcuts.

The following examples show how to use these shortcuts:

Example 1

Before Embedding:

csharp
public class TestClass
{
    public int GetValue(int a, int b, int c, int d)  
    {
        var value = a > b || c < d;

        return 0;
    }        
}
vb
Public Class TestClass
    Public Function GetValue(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer, ByVal d As Integer) As Integer
        Dim value = a > b OrElse c < d
        Return 0
    End Function
End Class

Select the “a > b” or “c < d” condition, and press Shift + 0 or Shift + 9 shortcut. You can use the Ctrl + W shortcut to select code and increase code selection.

After Embedding:

Example 2

This example shows how to use the Shift + 1 shortcut:

Select the “a > b” or “c < d” condition in the code snippet above, and press Shift + 1 :

See Also

C# Embeddings

Visual Basic Embeddings

XAML Embeddings