Search and replace content in files
You can search for a text string within a project, use different scopes to narrow your search process, exclude certain items from your search, find usages and occurrences.
The following video shows how you can search for any data in files.
note
In the video, the DataGrip user interface is Classic UI. Starting from version 2023.1, the New UI is available. For more information about the New UI, refer to the corresponding topic.
Press CtrlShift0F or select Edit | Find | Find in Files from the main menu.
In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press CtrlShift0F or from the context menu, select Find in Files. DataGrip places the highlighted string into the search field.
To see a list of your previous searches, press Alt0↓.
If you need, specify the additional options.
DataGrip lists the search strings and the files that contain them. If the search string is found several times on the same line of code, DataGrip merges the results in one line.
To do a multi-line search, click the icon to enter a new line, and press CtrlAlt0↓/CtrlAlt0↑ to browse through occurrences.
Check the results in the preview area of the dialog where you can replace the search string or select another string, press CtrlShift0F again and start a new search.
To see the list of occurrences in a separate tool window, click Open in Find Window. Use this window and its options to group the results, preview them, and work with them further.
If you want to see each new search result in a separate tab in the Find tool window, select the Open Results in New Tab checkbox on the bottom of the Find in Files dialog.
In the list of search results, right-click the result for which you want to copy a path and click Copy/Reference.
In the Copy window, select the path or reference you need.
You can use different options in the Find in Files dialog to adjust your search process.
Select options such as Words () or Match case () to find the exact word in a project or match the letter case.
With selected, DataGrip automatically escapes special regex symbols with backslash
\
when you search for a text string that contains them.note
Keep in mind that if you copy (Ctrl0C) the string first and then paste (Ctrl0V) it in the search field, the regex symbols will not be taken into account.
For more information about regex, refer to the search with regex documentation.
Click the icon to filter your search. For example, you can filter the search to omit comments or search only in comments instead.
Moreover, you can select the Scope option that offers you a list of predefined scopes for your search.
If you work without tabs, the scope Recently Viewed Files or Recently Changed Files option might become useful. You can also create your own custom scope, click the Browse icon () to open the Scopes dialog.
Use the File mask option to narrow your search to a specific file type. You can select the existing file type from the list, add a new file type, or add an additional file mask syntax to search for file types with certain patterns.
In the Find in Files dialog, select the File mask checkbox and from the list of file types, select the one you need.
DataGrip limits its search to the specified type.
If you don't find the file type you need in the list, enter your file type in the File mask field.
Press CtrlShift0R to open the Replace in Path dialog.
In the top field, enter your search string. In the bottom field, enter your replacement string.
Click one of the available Replace commands.
In the Find in Files dialog, click Open in Find Window to open the list of the search results in a separate window.
Using icons and context menu in the Find tool window, you can sort entries, exclude directories, navigate to the source code, and so on.
Check the following popular options:
If you want to exclude a directory from the results, select a directory and from the context menu, select Exclude.
To locate the result of the search in the editor, use the Jump to Source option from the context menu.
To return back to the Find in Files dialog, click on the left toolbar.
To sort the search entries, select View Options | Sort Members Alphabetically in Show Options Menu ().
For more information about the options and icon references of the Find tool window, refer to the Find tool window reference section.
Thanks for your feedback!