Replace text in files

You can use the Find in Files mode to search for text across specific folders on your computer. You can also create and save folder sets to reuse the same search locations in future searches.

To replace text in files

1. Press Ctrl+Shift+H or select Edit > Find and Replace > Replace in Files.

2. In the Find what field, enter the text you want to find.

Note

To use wildcard characters or regular expression syntax elements, enable Use > Wildcards or Use > Regular Expressions in step 5, then click the Expression Builder button arrow button next to Find what and choose the needed element from the list.

3. In Replace with, enter the replacement text or a replacement pattern.

Note

To reference tagged expressions captured in Find what, enable Use > Regular Expressions in step 5, then click the Expression Builder button arrow button and choose the needed references (for example, $1, $2) from the list. For more information, see Tagged expressions.

4. In Look in, select the Ellipsis button ellipsis button and choose folders to search:

  • Select one or more folders from Available folders. Click the Arrow button arrow to add them to Selected folders.

  • Optional: To save this combination for future use, in Folder set, select Unnamed folder set, enter the name for the set, and then click Apply.

After selecting the folders, click OK.

Replace in files tab and Choose search folders

5. Optional: Configure additional search options.

  • Match case – Finds text that matches the exact capitalization (for example, CREATE will not match create).

  • Match whole word – Finds only complete words, not parts of words (for example, table will not match tables or portable).

  • Use > Wildcards – Allows wildcard characters such as * and ?. For example, table* finds table, tables, and tablespace. After you select Wildcards, the Expression Builder button arrow button next to Find what becomes active—click it to choose the desired element from the list. For more information, see Wildcards for Find and Replace.

  • Use > Regular Expressions – Enables regex-based searches. After selecting Regular Expressions, the Expression Builder button arrow button next to Find what becomes active—click it to choose the desired element from the list. For more information, see Regular expressions.

Regex in the Find and Replace window

6. In the Look at these file types list, specify the file type to search. To search across all file types, select *.* all file types.

For a complete list of file type options, see File type filters later on this page.

7. Optional: Configure the result display options.

  • Keep modified files open after Replace All – Opens the modified files in the Document Editor so you can review the changes before saving.

  • Display file names only – Shows only file paths in the Find Results window without line numbers and replacement text.

8. Review and apply replacements:

  • Find Next – Locates the next occurrence without replacing it.

  • Replace – Replaces the current occurrence and moves to the next one. Continue clicking Replace to replace all occurrences one by one.

  • Replace All – Replaces all occurrences, including those you have skipped with Find Next.

9. Complete the process based on the replacement option you used:

  • Replace: Save your changes and close the documents. If a document has unsaved changes, dbForge Studio prompts you to save them. Click Yes to save, or No to discard the changes.

  • Replace All: Changes are saved automatically, unless Keep modified files open after Replace All is selected. In that case, review the changes before saving the modified files. To revert changes, select Edit > Undo in each file.

When you click Replace All, all replaced occurrences are listed in the Find Results window:

Replace in files results

In this example, the search pattern VALUES \('([^']+)', '([^']+)', ([0-9]+)\) finds VALUES clauses containing two quoted strings followed by a number in files within the selected folder. The replacement pattern VALUES ('$2', '$1', $3) applies the following changes:

  • Swaps the positions of the two strings while keeping the number unchanged.

  • Replaces VALUES ('Doe', 'John', 25) with VALUES ('John', 'Doe', 25) across all matching files.

For more information on how to navigate occurrences in the Find Results window, see Find Results window.

File type filters

This table describes the file type filters available for narrowing search and replace operations in the Find and Replace windows.

File Type Search Scope
*.* Search all file types.
*.dbd Search database diagram files.
*.rdb Search data reports files.
*.dcomp Search data comparison files.
*.scomp Search schema comparison files.
*.dgen Search data generation files.
*.ddoc Search database documentation files.
*.ssp Search SQL Server event profiler files.
*.txt Search text files.
*.xml Search XML files.
*.sql Search SQL script files.
*.sqlplan Search SQL execution plan files.
*.mdet Search master-detail browser files.
*.snap Search snapshot files.