Share via


How to: Search for Objects, Definitions, and References (Symbols)

You can use Object Browser, Navigate To, Find Symbol, or Go to Definition to search for objects, definitions, or references (symbols) in a solution.

In the Object Browser, you can type a search string to filter the names of the symbols that are displayed in the objects pane for the current browsing scope. For example, the string MyObject would return "MyObject," "MyObjectTest" and "CMyObject."

You can use the Navigate To feature to search for a symbol or file in the source code.

To perform a more advanced search, you can use the Find Symbol tab of the Find and Replace window. Results are displayed in the Find Symbol Results window. For more information, see Find Symbol, Find and Replace Window and Find Symbol Results Window.

Note

Right-clicking a symbol in the objects pane of the Object Browser and then clicking Find All References also displays results in the Find Symbol Results window.

You can also search for the original definition of a code element by right-clicking an instance of the element in the editor and then clicking Go To Definition.

Searching for Symbols By Using Object Browser

When you type a search string in the Search box in Object Browser, just the current browsing scope is searched. Use the Browse list to select a browsing scope. For more information about how to scope searches, see How to: Modify the Browsing Scope in the Object Browser.

To search for symbols by using a search string in Object Browser

  1. In Object Browser, in the Browse list, select a browsing scope.

  2. In the Search box, type all or part of a symbol name to search for, or select one from the drop-down list.

    Note

    Searches are not case-sensitive.

  3. Click Search.

    The objects pane displays just those symbol names in the browsing scope that include the search string. The string is highlighted in every match.

To clear the results

  • In Object Browser, click the Clear Search button on the toolbar.

    The objects pane now displays all the objects in the current browsing scope.

Searching for Symbols By Using Navigate To

Navigate To lets you find and navigate to a specific location in the solution, or explore elements in the solution. It helps you pick a good set of matching results from a query.

Navigate To dialog

To search for symbols or files in Navigate To

  1. On the Edit menu, click Navigate To.

  2. In the upper box, type a search string.

    Notice that results are displayed in the lower box as you type, and change as you type more. For example, if you type Click, then all symbol names that contain "Click" are displayed; however, if you add a space and the letter E, then the list is filtered to display just symbols that include "Click" and "E" (the space is treated as an and relationship).

The search results may include symbol definitions and file names in the solution, but does not include namespaces or local variables.

A search string can have multiple search terms, which must be separated by spaces. If a search term has an uppercase letter, the search for that term is case-sensitive; otherwise, the search is case-insensitive. File names are always case-insensitive for the first characters of the file name.

You can search for keywords that are contained in a symbol by using Camel casing and underscore characters to divide the symbol into keywords. For example, to find an "AddOrderHeader" symbol, you could search for "add", "order", "header", "order add", "AOH", and other combinations, as shown in the following table.

Symbol Name

Associated Keywords

Matching Search String Examples

AddOrderHeader

Add, Order, Header

"add", "order", "header", "order add", "AOH", "a o", "add ord", "OrderH"

update_customer

update, customer

"update", "customer", "customer upd", "update c"

The Navigate To syntax does not support special logic or special characters such as these:

  • Wildcard matching

  • Boolean logic operators, including and, or, &, |

  • Regular expressions

You can double-click a result to view the definition in the code.

To make an enhanced query, use Find Symbol.

Searching for Symbols By Using Find Symbol

Use the Find Symbol tab of the Find and Replace window to locate lines in your project code where a symbol is defined, referenced, or used. In particular, Find Symbol is useful as follows:

  • Searching for the definition of a symbol or discovering multiple definitions of a symbol.

  • Searching for references to a symbol and instances where it is used in your code.

  • Exploring object hierarchies in referenced and external components so that you can learn about their functionality.

Using Find Symbol differs from finding text, as follows:

  • Find Symbol lets you limit the search scope to include only symbols.

  • Indicates any available definitions of the symbol and references to it in the Find Symbol Results window.

  • Lets you search in external components for which you do not have the source code.

To search for symbols by using a search string on the Find Symbol tab of the Find and Replace window

  1. If any files that are to be searched are stored under source code control, check them out.

  2. Switch any open documents to Source view.

  3. On the Edit menu, click Find and Replace and then click Find Symbol.

  4. In the Look in list, select one of the following search scopes.

    • All Components scopes the search to all available components, including the current solution, its referenced components, the .NET Framework class library, and any components that you have added by using Add Other Components.

    • .NET Framework scopes the search to just the .NET Framework class library.

    • My Solution scopes the search to just the symbol names that are defined or referenced in the open solution.

    • Custom Component Set (Object Browser) scopes the search to just the components that are currently added to the Custom Component Set search scope of the Object Browser.

    • Custom Component Set (Find Symbol) scopes the search to just the components that are currently added to the Custom Component Set search scope Find Symbol.

    • Click the Browse (...) button to display the Edit Custom Component Set Dialog Box, and then select a custom set of search folders. For more information, see How to: Modify the Browsing Scope in the Object Browser.

  5. Under Find options, set the options you want, as follows:

    • Whole word filters the results so that only those that contain just the search string are displayed. For example, a search for MyObject would return "MyObject" but not "CMyObject" or "MyObjectC."

    • Prefix filters the results so that only those that begin with the search string are displayed. For example, a search for MyObject would return "MyObject" and "MyObjectTest" but not "CMyObject."

    • Substring returns all results that contain the search string. For example, a search for MyObject would return "MyObject", "MyObjectTest", and "CMyObject."

    Together with any of these options, you can also select Match case. This option further filters the results so that only those that match the case of the search string are displayed. For example, a search for MyObject when Match case is selected would return "MyObject" but not "myobject" or "MYOBJECT".

    Note

    Find and Replace settings remain in effect from search to search. For more information, see Find Symbol, Find and Replace Window.

  6. In the Find what box, enter the string or expression that you want to find.

    Note

    Wildcards and regular expressions cannot be used in Find Symbol searches.

  7. Click Find All to begin the search.

    The results are displayed in the Find Symbol Results Window. You can double-click a result to jump to its match in the code.

In the editor, when you want to search for the original definition of a code element, right-click the element and then click Go to Definition. You can search on elements such as members, types, variables, locals, and so forth.

Go to Definition uses compiler information to locate and display the original definition, even if your code uses overloads or type inferences, provided that the location is available to Visual Studio.

To search for the definition of a code element

  • In the editor, right-click the code element for which you want to find the definition, and then click Go To Definition.

    The module in which the element is originally defined, if it is available, is displayed on a new tab in the editor. If the definition is not available, an error message is displayed.

See Also

Tasks

How to: Navigate in the Object Browser

Reference

Find Symbol Results Window

Find Symbol Command

Code Definition Window

Other Resources

How to: Use Reference Highlighting

Change History

Date

History

Reason

August 2010

Modified Navigate To feature information.

Content bug fix.