Skip to main content
All docs
V22.2
  • Parentheses

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

      Menu

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

      Menu

    The following examples show how to use these shortcuts:

    Example 1

    Before Embedding:

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

    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