Skip to main content

Invert Selection


Inverts the code elements. The supported inversions are listed below:

  • Boolean literal (truefalse)
  • Equality operator (==!=)
  • Addition/substraction assignment (a += ba -= b)
  • Assignment (a = bb = a)
  • For-loop direction [for (int i = 0; i <= a.Length; i++)for (int i = a.Length; i > 0; i–)]


Available when the selection includes one or more supported code elements.


  1. Select one or more supported code elements.
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Invert Selection from the menu.


After execution, the Code Provider inverts all supported code elements in the selection as shown in the Purpose section.