Search your code
VSTS | TFS 2018 | TFS 2017
Use Code Search to search across all of your projects, find specific types of code, and easily drill down or widen your search
Go to Visual Studio Marketplace to install the extension in your VSTS account as an administrator. Non-administrative users can also go here to request the extension be added to VSTS. For more details, see Install an extension in the Marketplace documentation.
Only users with Basic access can use Code Search.
In the search textbox at the top right of the window, check that the text says Search code. The search text box may say Search work items. In this case, use the drop-down selector to change it.
If you don't see the selector in the Search box, open the Manage extensions page and check that Code Search is installed.
Enter a search string in the textbox, and press Enter (or choose the icon) to start your search.
The search page shows a list of the matching code files. The selected file has all instances of the search string highlighted.
If you see a list of work items, ensure that Code is selected in the top left.
Try assembling 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.
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.
Widen your search to all projects, or narrow it to specific areas and types of code, by selecting from the drop-down lists at the top of the page.
Use the tabs in the results page to view the history of the file and to compare versions of the file.
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.
Choose the filename link at the top of this column to open the file in a new Code Explorer window.