coderushforroslyn-403095-coding-assistance-selection-tools-selection-embedding-parentheses.md
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:
Choose the CodeRush | Shortcuts… menu item to open the Shortcuts options page.
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:
Before Embedding:
public class TestClass
{
public int GetValue(int a, int b, int c, int d)
{
var value = a > b || c < d;
return 0;
}
}
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:
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