Search your code
Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019 | 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
Prepare
Go to Visual Studio Marketplace to install the extension as an administrator. Non-administrative users can also request the extension is added. For more information, see Install an extension.
Note
Only users with Basic access can use Code Search.
Start searching
Open the Azure Repos section in Azure DevOps, for more information, see Web portal navigation).
Enter a search string in the textbox, and then select Enter (or choose
Search).
Open the Azure Repos section in Azure DevOps, for more information, see Web portal navigation).
Enter a search string in the textbox, and then select Enter (or choose
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
Search in the Search box, open the Manage extensions page and check that Code Search is installed (see Administer Search).
Enter a search string in the textbox, and press Enter (or choose
Search) to start your search.
View the results
The search page shows a list of the matching code files. The selected file has all instances of the search string highlighted (only the first 100 hits are highlighted).
If you see a list of work items, ensure that Code is selected in the top left.
Sort the results as you need using the drop-down list of properties, or by relevance.
Open the search results in a new browser tab from either search box by pressing Ctrl + Enter. In Google Chrome and Firefox press Ctrl + Shift + Enter to switch the focus to the new browser tab.
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. Then, enter the criteria value.
Note
As of the July 2019 update, the code search filters have been reduced from 39 to 19 through deprecation and merging.
You can find all instances of "ToDo" comments in your code simply by selecting
comment:
and typingtodo
.You can search in specific locations, such as within a particular path, by using a search string such as
Driver path:MyShuttle/Server
.You can search for files by name, such as
Driver file:GreenCabs.cs
, or just by file extension. For example, the search stringerror ext:resx
could 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.
You can use proximity operators like NEAR, BEFORE, and AFTER to search for files in the vicinity of a term.
See also full details of the search syntax.
The search page shows a list of the matching code files. The selected file has all instances of the search string highlighted (only the first 100 hits are highlighted).
If you see a list of work items, ensure that Code is selected in the top left.
Sort the results as you need using the drop-down list of properties, or by relevance.
Open the search results in a new browser tab from either search box by pressing Ctrl + Enter. In Google Chrome and Firefox press Ctrl + Shift + Enter to switch the focus to the new browser tab.
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. Then, enter the criteria value.
You can find all instances of "ToDo" comments in your code simply by selecting
comment:
and typingtodo
.You can search in specific locations, such as within a particular path, by using a search string such as
Driver path:MyShuttle/Server
.You can search for files by name, such as
Driver file:GreenCabs.cs
, or just by file extension. For example, the search stringerror ext:resx
could 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.
The search page shows a list of the matching code files. The selected file has all instances of the search string highlighted (only the first 100 hits are highlighted).
If you see a list of work items, ensure that Code is selected in the top left.
Sort the results as you need using the drop-down list of properties, or by relevance.
Open the search results in a new browser tab from either search box by pressing Ctrl + Enter. In Google Chrome and Firefox press Ctrl + Shift + Enter to switch the focus to the new browser tab.
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. Then, enter the criteria value.
You can find all instances of "ToDo" comments in your code simply by selecting
comment:
and typingtodo
.You can search in specific locations, such as within a particular path, by using a search string such as
Driver path:MyShuttle/Server
.You can search for files by name, such as
Driver file:GreenCabs.cs
, or just by file extension. For example, the search stringerror ext:resx
could 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 your entire organization. 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.
Choose the filename link at the top of this column to open the file in a new Code Explorer window.
Quickly search for work items containing the same search string, or search for the same string in your project's wiki.
How to search filters on a Multi Repo Multi branch environment
- Enter search text
NOT kjhasdhkjashdkjkhjdashkjdsaahsdkj
and hit enter. - Choose project filter as Team Project Name. Choose repository filter as your GIT repo. Choose branch filter as the wanted branch.
- Enter search text ext:json and hit enter. You can see your wanted results.
This search is a generic text, which will have matches in all repositories like NOT kjhasdhkjashdkjkhjdashkjdsaahsdkj. The long string could be any garbage text, which won't be present in any file. Adding a NOT before it inverts the logic and hence matches all files.