How to: Search Using Results Lists
You can perform bulk find and replace operations using the Find in Files and Replace in Files tabs of the Find and Replace window. These operations allow you to search files whether they are currently open in an editor, checked out to a local folder, or available on a network share.
Lists of matches found and changes made are displayed in the Find Results Windows. You can double-click any entry to jump to the line in your code where the match was found.
To review the keyboard shortcuts for search and replace operations, see Pre-defined Keyboard Shortcuts.
You can also search one or more open documents or windows using the Find/Command Box or the Quick Find and Quick Replace portions of the Find and Replace Window. Those operations let you jump from match to match in the active document; the Find Results windows are not displayed. For more information on performing such rapid search and replace operations, see How to: Search Interactively.
To find a string or expression in multiple files or folders
Switch any documents open in Design view editors to Source view.
Select Find and Replace from the Edit menu and choose Find in Files.
The Find in Files, Find and Replace Window opens.
In the Look in drop-down list, enter one or more folder or file names to search, separated by semicolon (;) delimiters.
—or—
Click Choose Custom Folders to create and select your own list of folders and files to search, using the Choose Search Folders Dialog Box.
Set Find options as needed.
Note
Find and Replace options are global, so they remain in effect from search to search. For more information on the available options, see Find in Files, Find and Replace Window and Replace in Files, Find and Replace Window.
To enable the use of Wildcards or Regular Expressions, select Use and choose the desired option.
In the File types list, select a set of file extensions from the list, or enter the extensions for the types of files to be searched, separated by semicolons (;). Use *.* to search all files in the folders listed in the Look in list.
In Result options, the Find Results 1 window is selected by default. To view the search results in a new window, select the Find Results 2 window option.
In the Find what text box, enter the string or expression that you want to find. To add special characters, click the triangular Expression Builder button next to this text box and choose Wildcards or Regular Expressions.
Note
For lists of available special characters, see Wildcards (Visual Studio) and Regular Expressions (Visual Studio).
Choose Find All to begin the search.
The matches for the search appear in the selected Find Results window. To jump to a search match, double-click its entry.
To search matches in a Find Results window
Conduct a Find in Files or Replace in Files operation.
Select the active Find Results window.
In the Find and Replace window, click the triangular View button on the Find tab and switch to Quick Find.
In the Look in field of Quick Find, select Current Window.
Enter a string or expression in the Find what field, and click Find Next.
This lets you scan the Find Results window for matches found in particular folders or files, or matches on lines of code where some other key term also occurs. For further information, see Find Results Windows.
Tip
You can also search incrementally against large sets of matches in the Find Results window to locate a specific search match. For more information, see How to: Search a Document Incrementally.
You can use Quick Find to scan through a lengthy list of matches in a Find Results window.
To replace a string or expression across an entire solution
Switch any documents open in Design view editors to Source view.
Select Find and Replace from the Edit menu and choose Replace in Files.
The Find and Replace window opens with the Replace in Files options displayed.
In the Look in drop-down list, select Entire Solution.
Set Find options as needed.
To enable the use of Wildcards or Regular Expressions, select Use and choose the desired option.
In the Look at these file types list, select file extensions from the list, or enter the extensions for the types of files to be searched, separated by semicolons (;). Use *.* to search all files in the folders listed in the Look in list.
Set Result Options as needed.
The Find Results 1 window is selected by default. To view the search results in a new window, select the Find Results 2 window option.
To enable Undo, select the Keep modified files open after Replace All option.
Warning
You can only use Undo on files that remain open for editing after the replace operation. If this option is not selected, files that were not already open for editing remain closed. No Undo option will be available in those files.
In the Find what text box, enter the string or expression that you want to find. To add special characters, click the triangular Expression Builder button next to this text box and choose Wildcards or Regular Expressions.
Note
For lists of available special characters, see Wildcards (Visual Studio) and Regular Expressions (Visual Studio).
To replace instances of the Find what string with another string, enter the replacement string in the Replace with text box.
—or—
To delete instances of the Find what string, leave the Replace with text box blank.
Choose Replace and continue choosing Replace until the last match in the last file has been replaced. Use Find Next to skip a single match you do not want to replace. Use Skip File to ignore all matches in a particular file move on to the next file in the solution.
—or—
Choose Replace All to replace all matches at once. A message box appears, listing the total number of replacements.
Note
The Replace All command replaces every match in every file. To reverse the Replace All operation in any open file, choose Undo from the Edit menu before saving that file.
See Also
Tasks
How to: Search a Document Incrementally
Reference
Quick Find, Find and Replace Window
Quick Replace, Find and Replace Window