Home > Navigation > CodeRush Code Navigation inside Visual Studio – Tab to Next Reference

CodeRush Code Navigation inside Visual Studio – Tab to Next Reference

June 21st, 2011

The Tab to Next Reference feature is the simplest and one of the most powerful navigation features of CodeRush. It allows you immediately see all references and navigate among them with ease. As the name says, the single Tab shortcut is used to navigate to the next reference of an identifier or a type reference under the editor caret. Hitting the Tab key again will move you to the next reference cyclically, in other words, you can tab to the next reference over and over again, even if you come back to the first reference where you started.

The underline visual indicator is used to highlight navigation references inside the code editor. By default, it has a pink color (which is customizable):

CodeRush Tab to Next Reference preview

You can also use the Shift+Tab shortcut to navigate backward to the previous reference, or the Escape key to move back to the location where you started. The feature works solution wide, opening a file with a reference if necessary. It also has cross-language support, e.g. if your solution contains projects written in different languages (e.g. C#, C++, VB) and you Tab over a System.Object type reference you might visit all of those projects.

For those who prefer to align code using the white space, the Tab to Next Reference is not available at the very beginning of an identifier or a type references by default, e.g.:

void GetCount(ref int result)
{
  [caret]int count = 100;
  [caret]result += count;
}

“[caret]” is indicating the editor caret position.

In both places the feature will insert the regular tab whitespace character, because this character is often used for source code aligning. If you would like to change this behavior, there is an alternative Tab shortcut binding (disabled by default) that allows the Tab key to take you to the next reference when the caret at the beginning of an identifier or a type reference.

To enable this shortcut, go to the IDE | Shortcuts options page in the CodeRush Options Dialog, find an alternative shortcut binding (Navigation | References | Nav Fields) and check the Enabled check box:

CodeRush Tab to Next Reference Shorcuts options page

Once it is enabled, to insert whitespace at the beginning of a line of code, you will need to use the Space bar instead of the Tab key, or move the editor caret to the left, so there’s at least one whitespace character to the right of the editor caret.

Color Options

To tweak the color of the underline highlighting, you can go to the Editor | Painting | Navigation Fields options page in the Options Dialog:

DXCore Navigation Fields options page

Behavior Options

The options specific to the Tab to Next Reference feature are located on the Editor | Navigation | Tab to Next Reference options page:

CodeRush Tab to Next Reference options page

Available options are:

  • Suppress availability when the caret is at the start of field declarations

If checked, Tab to Next Reference won’t be available at the start of a name of a field declaration, and hitting the Tab key will insert a regular whitespace character. Here’s a sample code with a caret position which is implied in the option:

class Test
{
  int [caret]MyField;
}

This option is useful if you prefer to align your code in the following way:

class Test
{
  int       Height;
  int        Width;
  double    Weight;
  string      Name;
}
  • Visualize references search

Shows a small hint with a progress bar while the references search is in progress. In most cases, you won’t notice a hint, because references search is ultra-fast and takes only milliseconds.

  • Navigate into designer code

If checked, Tab to Next Reference will skip references in designer-generated code inside “*.Designer.*” files.

Notes

The Tab to Next Reference feature relies upon the DXCore‘s background parse, and may not be available for a few seconds after a solution is opened. In this case, if you press Tab on an identifier before the background parse is complete, you will get a regular tab whitespace character inserted at the editor caret position instead of the expected feature behavior. You can encounter such behavior only in rare cases for very large projects with thousands of files. When the background parsing is in progress, you can see the “Processing solution items…” hint:

DXCore Processing Solution Items hint

If you don’t see this hint, it is safe to use any CodeRush features as well as the Tab to Next Reference.

—–
Products: CodeRush Pro, CodeRush Xpress
Versions: 11.1 and up
VS IDEs: any
Updated: Aug/30/2011
ID: C105

Similar Posts:

  1. September 14th, 2011 at 04:22 | #1

    Per http://www.skorkin.com/2010/07/coderush-xpress-features-differences-in-visual-studio-2008-and-2010/, this feature doesn’t exist in VS2010 for CodeRush Xpress. Does it exist in the the Pro version?

  2. September 14th, 2011 at 04:41 | #2

    @ Jack
    Yes, of course. The full CodeRush Pro version does not have any restrictions.