Team Services | TFS 2017
By using Code Search you can:
Search across all of your projects: Search in your own codebase and your partner teams' codebases. Use cross-project searches over all the code in your Team Services or TFS instance to search across your organization's entire codebase. Narrow your search by using project, repository, path, file name, and other filter operators. Use wildcards to widen your search and Boolean operators to fine-tune it.
Find specific types of code: Use code type filters to search for specific kinds of code such as definitions, references, functions, comments, strings, namespaces, and more. You can use Code Search to narrow down your results to exact code type matches. Navigate quickly to a method definition to understand its implementation simply by applying the definition filter, or scope the search to references in order to view calls and maximize code reuse.
Easily drill down or widen your search: When you find an item of interest, simply place the cursor on it and use the shortcut menu to quickly search for that text across all your projects and files. Easily trace how your code works by using the shortcut menu to search for related items such as definitions and references - directly from inside a file.
After you install Code Search, you'll see the search textbox in the Team Services or Team Foundation Server (TFS) title bar.
Only users with Basic access can use Code Search.
Notice that, when you are in a project, you can use the selector to switch between searching for code and searching for work items.
For more details about searching for work items, see Work Item Search.
If you don't see the selector in the Search box, open the Manage extensions page and check that Code Search is installed.
From anywhere in Team Services or TFS, make sure the search text box in the title bar contains Search code, enter a search string in the textbox, and press Enter (or choose the icon) to start your search. Or you can assemble more complex search strings using the operators and functions listed in the handy drop-down list.
Select the filter function or code type you want to include in your search string from the list, and type the criteria value. For example:
You can find all instances of "ToDo" comments in your code simply by selecting
You can search in specific locations, such as within a particular path, by using a search string such as
You can search for files by name, such as
Driver file:GreenCabs.cs, or just by file extension. For example, the search string
error ext:resxcould be useful when you want to review all error strings in your code. But even if your plain text search string (without specific file type functions) matches part of a filename, the file appears in the list of found files.
You can combine two or more words by using Boolean operators; for example,
validate OR release.
You can find an exact match to a set of words by enclosing your search terms in double-quotes. For example,
"Client not found".
You can use the code type search functions with files written in C#, C, C++, Java, and Visual Basic.NET.
See also full details of the search syntax.
After this, you can use the textbox in the search results page to enter simple search strings, or to select functions and enter the filter criteria.
Open the search results in a new browser tab from either search box by pressing Ctrl + Enter or by holding Ctrl and clicking the icon. In Google Chrome, press Ctrl + Shift + Enter to switch the focus to the new browser tab.
Use the rich search results page
One of the major advantages of Code Search is the fact that it displays the full contents of the files for each result. This makes it easier for you to scan each match within a result file in the context of the containing file and the code that surrounds it.
The results page shows, in the left column, the number of hits in each project and repository. The selected projects and any selected Git repositories are always at the top of these lists. Notice how the hit counts are provided for projects and repositories that were not selected.
The second column in the previous screenshot shows the list of matching documents; by default it shows the first 50 but there is a Show more link at the end of the list to display more. In the center column, you see:
- The project, repository, and file name delimited with ">" characters
- The total number of matches in this file
- The full path and name of this file
The right column of the results page shows the matching file with all the hits highlighted. Scroll through the highlighted matches in all the matching files using the up and down arrow icons located near the top right of the page, or F8 and Shift+F8 on your keyboard.
Choose the filename link at the top of this column to open the file in a new Code Explorer window.
- Choose your search scope
- Advanced Code Search options
- Rich Code Search results
- Set up and administration