Search your code

Azure DevOps Services | 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


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.

Only users with Basic access can use Code Search.

Start searching

  1. Open the Azure Repos section in Azure DevOps (see Web portal navigation).

  2. Choose the start search icon icon at the top right of the window to show the search textbox.

    The Code Search textbox in the title bar

  3. Enter a search string in the textbox, and press Enter (or choose the start search icon icon) to start your search.

  1. 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.

    Switching between searching for code and work items

    If you don't see the select search type selector in the Search box, open the Manage extensions page and check that Code Search is installed (see Administer Search).

    Checking that the extension is installed

  2. Enter a search string in the textbox, and press Enter (or choose the start search icon icon) to start your search.

View the results

  1. 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).

    Search results

    If you see a list of work items, ensure that Code is selected in the top left.

  2. Sort the results as you need using the drop-down list of properties, or by relevance.

    Sort drop-down list

    Open the search results in a new browser tab from either search box by pressing Ctrl + Enter or by holding Ctrl and clicking the start search icon icon. In Google Chrome and Firefox press Ctrl + Shift + Enter to switch the focus to the new browser tab.

  3. 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.

    Search from title bar

    • You can find all instances of "ToDo" comments in your code simply by selecting comment: and typing todo.

    • 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 string error 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.

  4. 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 drop-down lists to widen or narrow your search

  5. Use the tabs in the results page to view the history of the file and to compare versions of the file.

    Use tabs to view history and compare files

  6. Choose the filename link at the top of this column to open the file in a new Code Explorer window.

    Open the file in Code Explorer

  7. Quickly search for work items containing the same search string, or search for the same string in your project's wiki.

    Search for work items or wiki containing the same search string

How to search filters on a Multi Repo Multi branch environment

  1. Enter search text NOT kjhasdhkjashdkjkhjdashkjdsaahsdkj and hit enter.
  2. Choose project filter as Team Project Name. Choose repository filter as your GIT repo. Choose branch filter as the wanted branch.
  3. 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.

Next step