Skip to main content
All docs
V22.2

Caps as a Modifier

  • 5 minutes to read

The Caps as a Modifier feature allows you to use the Caps Lock key as a shortcut modifier like Ctrl, Shift, or Alt to create shortcut bindings for your favorite CodeRush commands. You can also use the Caps Lock key as a modifier to quickly access a wide range of CodeRush functionality (refactorings, code providers, and smart navigation).

For example, select a method parameter and press the Caps Lock key along with the letter F to declare a field variable initialized with the selected method parameter. The Caps+F shortcut runs the Declare Field with Initializer code provider.

caps-f

The Caps as a Modifier feature also lowers the risk of accidentally engaging Caps Lock - a single tap and release no longer toggles the Caps Lock state when Visual Studio is active. If you need to toggle Caps Lock on or off (with this feature enabled), quickly tap Caps Lock twice.

When Caps Lock is on, CodeRush indicates the Caps Lock state with a sound and shows a toast in the bottom right of Visual Studio. This toast alerts you that Caps Lock is engaged.

caps-on-toast

To disengage Caps Lock, double-tap the Caps Lock key again. The toast alerts you that you have returned to the normal keyboard entry.

caps-off-toast

How to Enable

Use one of the following ways to enable the Caps as a Modifier feature:

Setup Wizard

  1. Open the CodeRush menu and click the “Setup Wizard…” menu item to run the Setup wizard.

    wizard-menu-item

    Note

    In Visual Studio 2019, CodeRush menu is placed into a new location - in Visual Studio Extensions menu. You can reposition the CodeRush menu back to the top level of the Visual Studio menu bar in Visual Studio 2019 version 16.4 or later. See the following topic for more information: First Steps.

  2. Check the “Enable Caps as a Modifier” checkbox on the “Caps as a Modifier” setup page:

    enable-caps-on-wizard-page

  3. Click Finish to save this setting and close the CodeRush Setup wizard.

Quick Setup Options Page

  1. Open the CodeRush menu and click the “Options…” menu item to open the Options page.

    options-menu-item

  2. Enable the “Caps as a Modifier” option on the “Quick Setup” options page.

    enable-caps-on-quick-setup-page

Learning CodeRush Solution

Once you enable Caps as a Modifier, you can access numerous CodeRush features. You can use the “Learning CodeRush” solution to learn Caps shortcuts and practice CodeRush features.

To open the “Learning CodeRush” solution, select the CodeRush | Support | Open Learning CodeRush Solution… menu item or run the Setup wizard and click Open Learning CodeRush Solution on the Setup Wizard’s last page.

learning-solution

The “Learning CodeRush” solution loads in a new instance of Visual Studio. To start practice, open the “StartHere.cs” file.

Caps Lock Features

Toggle Code

Press Caps Lock+Space to run one of the following refactorings that change code from one state into another:

The screencast below shows how to make the variable declarations implicit:

caps-space-make-implicit

You can also use the Caps+Space shortcut to perform the following actions:

Remove Redundant Code

Place the caret in a redundant type/type member and press Caps Lock+Delete to remove it. The Caps+Delete shortcut can run one of the following refactorings depending on the code context:

For example, press Caps+Delete to remove an unused member.

caps-delete

Add New Code

Press Caps Lock+Insert to add new code at the caret. The Caps+Insert shortcut runs one of the following code providers:

  • Add Missing Constructors (available when the caret is in the class name)
  • Add to Interface (available on the name of a new member inside a class that implements an interface)
  • Add Parameter (available inside a parameter list to a method declaration or an argument list on a method call)

The following screencast shows how to add missing constructors:

caps-insert

Single-key Declarations

You can declare classes, members, and locals with a single keystroke when the caret is in an undeclared class reference, member reference, or unassigned expression. You can use the following shortcuts:

  • Caps+C to declare a class.
  • Caps+M to declare a method.
  • Caps+P to declare a property.
  • Caps+F to declare a field.
  • Caps+L to declare a local variable for the unassigned expression at the caret.
  • Caps+Q to declare a constant.

The following screencast shows how to declare an initialized property:

caps-p

Smart Navigation

Press Caps Lock+Down/Up to navigate among sibling nodes in the code. For example, you can navigate between variables and press Caps Lock+Space to make the variable declarations implicit.

smart-navigation-in-action

For more information, refer to the following topic: Smart Navigation.

Bind Caps Lock Shortcuts

Follow the steps below to bind a Caps shortcut to a Visual Studio or CodeRush feature:

  1. Know the command name. If you want to bind to a Visual Studio command, you must know the exact text of the VS command before you take the next step. You can get a list of all Visual Studio commands in the Visual Studio Options dialog on the Keyboard page.

  2. Add a new shortcut. Open the CodeRush Shortcuts options page and add a new shortcut.

    custom-caps

    Refer to the following topic for details: Add a New Shortcut.

Customize Caps as a Modifier

You can configure the “Caps as a Modifier” feature on the IDE | Caps as a Modifier options page.

custom-caps