Jetbrains найти и заменить
You can search and replace text in the entire solution, project, any directory with its nested hierarchy, or in any scope. Explore search results in the preview tab or in the Find tool window.
If you are looking for types, members, files, actions, or settings, use Search Everywhere ( Ctrl+T or Shift twice).
Search and replace options
Alt+Down
Show the history of the recent entries.
Clear the search field.
Enable entering the search string in several lines. Even without this option, you can search for multiline matches with regular expressions and escape characters.
Distinguish between upper and lowercase letters while searching.
Search for whole words only, that is, for character strings separated with spaces, tabs, punctuation, or special characters.
This option is unavailable if Regular expressions is selected.
Process the search query as a regular expression.
Navigate through the occurrences of the search string.
Alt+F7
Show search results in the Find window.
Add the next found occurrence to a multiple selection.
Remove the found occurrence from a multiple selection.
Create a multiple selection that contains all the found occurrences.
Confine search and replacement to the current selection in the editor.
Invoke the list of additional options, for example to confine the search to comments or string literals.
When replacing strings, use the casing of each occurrence for replacements. For example, when replacing foo with bar , Foo will be replaced with Bar , and FOO with BAR .
You can search for a text string within a project, use different scopes to narrow your search process, find occurrences, and exclude certain items from the search.
Narrow your search
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, IntelliJ IDEA automatically escapes special regex symbols with backslash \ when you search for a text string that contains them.
Keep in mind that if you copy ( Ctrl+C ) the string first and then paste ( Ctrl+V ) it in the search field, the regex symbols will not be taken into account.
For more details on 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.
Select one of the displayed options such as Module or Directory to limit your search.
Moreover, you can select the Scope option that offers you a list of predefined scopes for your search. For example, you can limit your search only to the open files in your project or you can search in a class hierarchy.
If you work without tabs, the scope Recently Viewed Files or Recently Changed Files option might become quite useful. You can also create your own custom scope, click the Browse icon () to open the Scopes dialog.
Find text in solution
If you want to search only specific part of your solution, select the corresponding node in the Solution Explorer.
Press Ctrl+Shift+F or choose Edit | Find | Find in Files .
In the Find in Files dialog, enter the search string.
If necessary, specify the search options.
You can click or press Alt+Down to show the list of recent search entries.
To search for a multi-line fragment, click in the search box or press Ctrl+Shift+Enter
To return to a single-line mode, press Backspace .
To restrict your search by file types, select File mask , and then choose the desired mask or specify a new one using wildcards:
* to substitute a set of any characters,
? to substitute a single character,
! to exclude files. Note that ! should go first in a particular file name pattern, for example, !*.xml
You can specify multiple file masks, delimited with commas (for example, *.xml,a?c.sql,!*.html ).
Note also, that negated pattern (for example, !*.min.js ) has implicit inclusion pattern * . This allows avoiding such constructs as *, !*.min.js for every file except minified javascript).
If there is no search text and this checkbox is selected, JetBrains Rider will find all files matching the specified mask, regardless of their contents.
To restrict your search by a project, directory or specific scope, use the selector under the search field.
When invoked for the second (and subsequent) time, the dialog opens with the scope that has been selected previously. For example, if the scope has been Directory , the next time you invoke the dialog, the scope again will be Directory .
Results that match your query are listed as you type. When the query is complete, you can study the results:
Press Up / Down to select matching strings and study their context in the preview pane.
Edit code right in the preview pane as it is a functional editor where actions such as Ctrl+F or Alt+Enter are available.
You can select text and press Ctrl+Shift+F to start a new search right from the preview pane.
Press Enter to open the selected result in the editor.
Click Open in Find Window Ctrl+Enter to see all of the results in the Find window.
If the search takes too much time, click Background in the search progress window. In this case the search progress is indicated in the Status bar.
If the file that JetBrains Rider tries to load exceeds 20 MB, it will be ignored. To configure the file size, use the idea.max.content.load.filesize property in the idea.properties.
In contrast to other navigation and search commands, the results of Find in Path Ctrl+Shift+F are by default displayed in the same tab of the Find window. If you want the results of previous textual searches to be preserved in different tabs, click Show Tab Options in the bottom left corner of the Find in Path popup and choose Open Results in New Tab :
Replace the search string in a project
Press Ctrl+Shift+R to open the Replace in Path dialog.
In the top field, enter your search string. In the bottom field, enter your replacement string.
For example, if you want to replace a variable name with a new name for a large project, use the replace in path instead of rename refactoring since your variable can appear in the config files as well.
Click one of the available Replace commands.
Manage your search
IntelliJ IDEA lets you adjust your search process and perform various actions with the displayed search results.
If you want to see the list of previous searches, press ⌥↓ in the search field.
If you want to enter a multi-line string, click the icon in the search field for a new line.
With selected, IntelliJ IDEA automatically escapes special regex symbols with backslash \ when you search for a text string that contains them.
Keep in mind that if you copy ( Ctrl+C ) the string first and then paste ( Ctrl+V ) it in the search field, the regex symbols will not be taken into account.
For more details on regex , refer to the search with regex documentation.
Use the and arrows to navigate to the previous or the next occurrence.
Work with the list of occurrences Alt+F7 in the Find tool window, where you have other options, for example, to group your results or to open them in a separate window.
Click the or icon to add a selection of the next occurrence or deselect the previous occurrence Alt+J or Alt+Shift+J .
If you want to quickly replace the target of your search in the whole file, press Ctrl+Alt+Shift+J and type a new string.
You can narrow your search when you click , in the search field, or click to select a scope for your search.
You can press ^⌥X (previously known as ⌥G ) to quickly toggle the Regex option. You can use regular expressions to opt for more challenging searches.
Press Ctrl+F7 to see usages of any element in the opened file.
If you don't want IntelliJ IDEA to highlight all found usages in the file, open the Settings/Preferences dialog ( Ctrl+Alt+S ) and on the Editor | General page clear the Highlight usages of element at caret option.
Press Alt+F7 to search for usages beyond the current file or Ctrl+Alt+F7 to open the search results in a separate popup. If you need to configure some options before the search, press Ctrl+Alt+Shift+F7 to open the Find Usages dialog.
Use regex capturing groups and backreferences
You can put the regular expressions inside brackets in order to group them. Each group has a number starting with 1, so you can refer to (backreference) them in your replace pattern. Note that the group 0 refers to the entire regular expression. However, you can refer to the captured group not only by a number $n , but also by a name $ .
For example, for the numbered capturing groups, use the following syntax:
You can quickly find and replace text strings in the current document. Using different options, you can narrow your search process, use regular expressions in your search, and manage your search results.
Work with the search results in the Find tool window
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 on the options and icon references of the Find tool window, refer to the Find tool window reference section.
When you want to search and replace specific patterns of text, use regular expressions. They can help you in pattern matching, parsing, filtering of results, and so on. Once you learn the regex syntax, you can use it for almost any language.
Press Ctrl+R to open the search and replace pane.
If you need to search and replace in more than one file, press Ctrl+Shift+R . For more detailed information, refer to Search and replace a target within a project.
Enter a search string in the top field and a replace string in the bottom field.
Click to enable regular expressions. If you want to check the synax of regular expressions, hover over and click the Show expressions help link.
When you search for a text string that contains special regex symbols, IntelliJ IDEA automatically escapes them with backlash \ in the search field.
Keep in mind that if you copy ( Ctrl+C ) the string first and then paste ( Ctrl+V ) it in the search field, the regex symbols will not be taken into account.
For example, if you need to find . , type \. in the search field.
IntelliJ IDEA can also match a letter case when you enter a range of characters in your search field.
For example, if you want to search for only uppercase characters, type the following in the search field:
To search and replace more complicated patterns, use the structural search and replace.
If is unselected in the search field, IntelliJ IDEA searches for both lower and upper cases.
Select in the search field to match the case of the specified range.
When you browse the occurrences, IntelliJ IDEA displays the replacement hints, so you can view the potential results before clicking the Replace button.
See RegEx syntax for more details.
Replace text in the solution
Press Ctrl+Shift+R or select Edit | Find | Replace in Path from the main menu.
In the Replace In Path dialog, specify the search and replace strings, search options, and the scope.
If you specify the search and/or replacement text through a regular expression, use the $n format in back references (to refer to a previously found and saved pattern).
To use a backslash character \ in a regular expression, escape the meaningful backslash by inserting three extra backslashes in a preposition: \\\\ .
You can view and analyze the matching occurrences the same way as with the search. Note the if you click Open in Find Window Ctrl+Enter , replace commands will be still available for the results.
Click Replace All to replace all matching occurrences or Replace to replace items one by one.
Search in the specific file types
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.
IntelliJ IDEA 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.
For example, use the following syntax to search only in gradle files: *.gradle .
You can manually add a file mask in the search field. If necessary, specify several file types separating them with commas.
Find text in solution
If you want to search only specific part of your solution, select the corresponding node in the Solution Explorer.
Press Ctrl+Shift+F or choose Edit | Find | Find in Files .
In the Find in Files dialog, enter the search string.
If necessary, specify the search options.
You can click or press Alt+Down to show the list of recent search entries.
To search for a multi-line fragment, click in the search box or press Ctrl+Shift+Enter
To return to a single-line mode, press Backspace .
To restrict your search by file types, select File mask , and then choose the desired mask or specify a new one using wildcards:
* to substitute a set of any characters,
? to substitute a single character,
! to exclude files. Note that ! should go first in a particular file name pattern, for example, !*.xml
You can specify multiple file masks, delimited with commas (for example, *.xml,a?c.sql,!*.html ).
Note also, that negated pattern (for example, !*.min.js ) has implicit inclusion pattern * . This allows avoiding such constructs as *, !*.min.js for every file except minified javascript).
If there is no search text and this checkbox is selected, JetBrains Rider will find all files matching the specified mask, regardless of their contents.
To restrict your search by a project, directory or specific scope, use the selector under the search field.
When invoked for the second (and subsequent) time, the dialog opens with the scope that has been selected previously. For example, if the scope has been Directory , the next time you invoke the dialog, the scope again will be Directory .
Results that match your query are listed as you type. When the query is complete, you can study the results:
Press Up / Down to select matching strings and study their context in the preview pane.
Edit code right in the preview pane as it is a functional editor where actions such as Ctrl+F or Alt+Enter are available.
You can select text and press Ctrl+Shift+F to start a new search right from the preview pane.
Press Enter to open the selected result in the editor.
Click Open in Find Window Ctrl+Enter to see all of the results in the Find window.
If the search takes too much time, click Background in the search progress window. In this case the search progress is indicated in the Status bar.
If the file that JetBrains Rider tries to load exceeds 20 MB, it will be ignored. To configure the file size, use the idea.max.content.load.filesize property in the idea.properties.
In contrast to other navigation and search commands, the results of Find in Path Ctrl+Shift+F are by default displayed in the same tab of the Find window. If you want the results of previous textual searches to be preserved in different tabs, click Show Tab Options in the bottom left corner of the Find in Path popup and choose Open Results in New Tab :
Find the search string in a project
From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F .
In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . IntelliJ IDEA places the highlighted string into the search field.
To see a list of your previous searches, press Alt+Down .
If you need, specify the additional options.
IntelliJ IDEA lists the search strings and the files that contain them. If the search string is found several times on the same line of code, IntelliJ IDEA merges the results in one line.
To do a multi-line search, click the icon to enter a new line, and press Ctrl+Alt+Down / Ctrl+Alt+Up 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 Ctrl+Shift+F 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, click on the bottom of the Find in Files dialog and select the Open Results in New Tab checkbox.
Find in selection
You can search for a text string inside the multi-line selection.
IntelliJ IDEA handles replacing in the multi-line selection the same way.
Select a multi-line fragment and press Ctrl+F .
Click and type your search string. IntelliJ IDEA will search for the target inside the selected fragment first.
If you release , IntelliJ IDEA will switch the search process back to the whole file.
If you want to search for the multi-line fragment itself, select it and press Ctrl+F .
Find the search string in a file
Open your file in the editor.
Press Ctrl+F or select Edit | Find | Find from the main menu.
If you want to extend the search of your target beyond the current file, press Ctrl+Shift+F . For more information, see Search and replace a target within a project.
In the search field that opens, enter your search string. IntelliJ IDEA highlights the results of your search in the file. Alternatively, in the editor, highlight the string you want to find and press Ctrl+F . IntelliJ IDEA places the highlighted string into the search field.
Place a caret at any string in your file and press Ctrl+F to find its occurrences or from the main menu, select Edit | Find | Next Occurrence of the Word at Caret .
Search text in the current document
Press Ctrl+F or choose Edit | Find | Find from the main menu. The search pane appears at the top of the active editor.
If necessary, specify the search options.
In the search field, start typing the search string:
As you type, the first occurrence of the search string after the current cursor position is selected; the other occurrences are highlighted in the editor. In addition, the matching occurrences are marked in the scrollbar with stripes.
To search for a multi-line fragment, click in the search box or press Ctrl+Shift+Enter
To return to a single-line mode, press Backspace .
To search for symbols declared or used in the current document, start typing a symbol name or its Camel-Cased abbreviation, and then press Ctrl+Space to choose from the matched items.
Replace text in the current file
Press Ctrl+R or choose Edit | Find | Replace from the main menu. The search and replace pane appears on top of the active editor.
In the search field, start typing the search string. As you type, the matching occurrences are highlighted in the editor, and a Replace popup dialog opens at the first occurrence, suggesting to replace the current occurrence, or all of them, with an empty string.
Type the replacement string.
Click Replace All to replace all matching occurrences or Replace to replace items one by one.
Alternatively, you can click Exclued to skip the current occurrence and exclude it from the Replace all operation. The button for this occurrence changes to Include . Use Shift+F3 and F3 to move focus to other occurrences that you want to exclude or include.
Search and replace options
Alt+Down
Show the history of the recent entries.
Clear the search field.
Enable entering the search string in several lines. Even without this option, you can search for multiline matches with regular expressions and escape characters.
Distinguish between upper and lowercase letters while searching.
Search for whole words only, that is, for character strings separated with spaces, tabs, punctuation, or special characters.
This option is unavailable if Regular expressions is selected.
Process the search query as a regular expression.
Invoke the list of additional options, for example to confine the search to comments or string literals.
When replacing strings, use the casing of each occurrence for replacements. For example, when replacing foo with bar , Foo will be replaced with Bar , and FOO with BAR .
You can quickly find and replace text strings in the current document. Using different options, you can narrow your search process, use regular expressions in your search, and manage your search results.
If you are looking for types, members, files, actions, or settings, use Search Everywhere ( Ctrl+T or Shift twice).
Explore the search results
To initiate a new search, do one of the following (depending on the current focus):
If the editor has the focus, press Ctrl+F .
If the search field has the focus, press Ctrl+A
In both cases, the existing search string will be selected, and you can start typing a new one.
To jump between occurrences, do one of the following:
Press Shift+F3 (jump to previous selection) or F3 (jump to next selection).
Use the or buttons in the Search pane.
Click the gutter stripes.
Next to the search field, you will see the total number of found occurrences and the number of the selected occurrence.
You can click or press Alt+Down to show the list of recent search entries.
Use Code completion in the Find and Replace panes. Start typing a search string, press Ctrl+Space , and select the appropriate word from the suggestion list.
With the Find and Replace pane already opened, use Ctrl+R or Ctrl+F to toggle between panes. Thus, the search and replace strings are preserved.
To close the search pane and switch the focus to the editor, press Escape .
When you press Escape and return the focus to the editor, the first search match stays selected, so you can copy Ctrl+C or cut Ctrl+X it, or start typing to replace the selection.
You can also add multiple carets and selection ranges to the occurrences of the search string — click Alt+J and Alt+Shift+J to select or unselect occurrences one by one, or click Ctrl+Alt+Shift+J to select all occurrences.
Replace the search string in a file
Press Ctrl+R or select Edit | Find | Replace from the main menu to open the Replace in File window.
In the top field, enter your search string. In the bottom field, enter your replacement string. If you need to preserve the case, click located in the replace field.
Click for a multi-line replace. For example, if you want to replace a comma with a comma and a new line, enter a comma in the search field and a comma and the new line in the replace field.
Click Replace to replace items one by one, Replace all to replace all items in your file, and Exclude to omit some items from replacing.
The options that appear in the Replace window, are similar to the Find window and you can refer to the manage the search results section.
Toggle between Find and Replace
To switch from the Find in Files to Replace In Path window, press Ctrl+Shift+R .
To switch from the Replace In Path to Find in Files window, press Ctrl+Shift+F .
Читайте также: