Advanced Code Search options

Last Update: 4/7/2017

Team Services | TFS 2017

You can:

Go back Back to Search overview

Syntax for simple and compound searches

Use simple search strings for words or phrases. The default is a whole word search; for example, a search for "valid" will not find instances of the word "validation". However, searches are not case-sensitive.

Narrow your search with Boolean operators

Narrow your search by using Boolean operators to combine search criteria. Combine multiple search criteria using AND, OR, or NOT (they must be uppercase).

Use parentheses to specify the precedence of the operations when you use more than one Boolean operator. By default, a search combines all the words you enter using the AND operator so that it will return only files that contain all of the words you entered.

For example:

  • validate AND revisit finds files that contain both the words validate and revisit. Note that AND is the default operator, and so this is equivalent to the search string validate revisit.
  • validate OR revisit finds files that contain either of the words validate or revisit.
  • validate NOT revisit finds files that contain the word validate but not the word revisit.
  • (validate NOT revisit) OR "release delayed" finds files that contain the word validate but not the word revisit or files that contain the phrase release delayed.

Use Boolean operators to refine your search

To find an exact match to a set of words, enclose your search terms in double-quotes. For example, "Client not found"

Broaden your search with wildcards

Use the wildcard characters * and ? to broaden your search criteria. For example:

  • CodeSenseHttp* finds files containing words that start with CodeSenseHttp, such as CodeSenseHttpClient and CodeSenseHttpClientTest.
  • CodeX23?R finds files containing words that start with CodeX23, have any alphanumeric character next, and end with R. For example, CodeX234R and CodeX23QR.

You can use wildcard characters anywhere in your search string except as a prefix in a simple search string or a query that uses a code type filter. For example, you cannot use a search query such as *RequestHandler or class:?RequestHandler. However, you can use prefix wildcards with the other search filter functions; for example, the search query strings file:*RequestHandler.cs and repo:?Handlers are valid.

You can use more than one ? wildcard to match more than one character.

Horizontal line
Warning No results found for ...
If there is a very large number of hits when using a wildcard search, such as when using a very simple wildcard search string, you may see a message that no matching files were found. In this case, narrow your search to reduce the number of matches. For example, specify more characters of the word(s) you want to find, or add a condition or filter to limit the number of possible matches.
Horizontal line

Functions to find specific types of code

As you type in the search box, select functions and keywords from the drop-down list to quickly create your query. Use the Show more link to display all the available functions and keywords. Mix and match the functions as required.

Select functions from the drop-down list

You can also select one or a combination of filters from the list in the left column. Again, the Show more link displays all the available functions and keywords.

Select functions using the left column checkbox list

Alternatively, you can type the functions and parameters directly into the search box. The following table shows the full list of functions for selecting specific types or members in your C#, C, C++, Java, and Visual Basic.NET code.

To find code where findThis appears as a ... ... search for argument arg:findThis
Argument arg:findThis
Base type basetype:findThis
Calling function caller:findThis
Class definition or declaration class:findThis
Class declaration classdecl:findThis
Class definition classdef:findThis
Comment comment:findThis
Constructor ctor:findThis
Declaration decl:findThis
Definition def:findThis
Destructor dtor:findThis
Enumerator enum:findThis
Extern extern:findThis
Field field:findThis
Friend function friend:findThis
Function func:findThis
Function declaration funcdecl:findThis
Function definition funcdef:findThis
Global global:findThis
Header header:findThis
Interface interface:findThis
Macro macro:findThis
Macro definition macrodef:findThis
Macro reference macroref:findThis
Method method:findThis
Method declaration methoddecl:findThis
Method definition methoddef:findThis
Namespace namespace:findThis
Property prop:findThis
Reference ref:findThis
String literal strlit:findThis
Struct struct:findThis
Struct declaration structdecl:findThis
Struct definition structdef:findThis
Template argument tmplarg:findThis
Template specification tmplspec:findThis
Type type:findThis
Typedef typedef:findThis
Union union:findThis

Functions to select projects, repositories, paths, and files

Functions make it easy to narrow the search to specified locations, specific types of files within these locations, or specified filenames. Mix and match the functions as required.

Narrow the search to a specific location using the proj, repo, or path filters:

  • QueueJobsNow proj:Fabrikam finds all occurrences of the word QueueJobsNow in the Fabrikam project.
  • QueueJobsNow repo:Contoso finds all occurrences of the word QueueJobsNow in the Contoso repository.
  • QueueJobsNow path:VisualStudio/Services/Framework finds all occurrences of the word QueueJobsNow in the path VisualStudio/Services/Framework and its sub-paths.
  • Enclose the argument to the filter in double-quotes if it contains a space. For example: QueueJobsNow path:"VisualStudio/Windows Phones and Devices/Services".

Narrow the search to specific files using the file or ext filters:

  • QueueJobsNow file:queueRegister* finds all occurrences of the word QueueJobsNow in all files where the filename starts with queueRegister.
  • QueueJobsNow ext:cs finds all occurrences of the word QueueJobsNow in only C# source files.
  • A plain text search string that does not include file type functions will also find files where the string matches part of the filename.

Select projects, repositories, paths, and files using functions

See also

Go back Back to Search overview

Got feedback?

Question Send your feedback to Post your ideas and feature requests on UserVoice.