Search for a target within a file在文件中搜索目标
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.使用不同的选项,您可以缩小搜索过程,在搜索中使用正则表达式,以及管理搜索结果。
Find the search string in a file在文件中查找搜索字符串
-
Open your file in the editor.在编辑器中打开文件。 -
Press Ctrl+F or select按Ctrl+F或从主菜单中选择“编辑”|“查找”|“查找”。 from the main menu. -
In the search field that opens, enter your search string.在打开的搜索字段中,输入搜索字符串。WebStorm highlights the results of your search in the file.WebStorm会在文件中突出显示搜索结果。Vice versa, when you highlight a string in the editor and press Ctrl+F, WebStorm places the highlighted string into the search field.反之亦然,当您在编辑器中高亮显示字符串并按Ctrl+F时,WebStorm会将高亮显示的字符串放入搜索字段。Alternatively, just position the caret at the string to search and press Ctrl+F or select或者,只需将插入符号置于要搜索的字符串处,然后按Ctrl+F或从主菜单中选择“编辑”|“查找”|“下一个出现在插入符号处的单词”。 from the main menu.
Find in selection在选择中查找
You can search for a text string inside the multi-line selection.可以在多行选择中搜索文本字符串。
-
Press Ctrl+F and select a multi-line fragment.按Ctrl+F并选择多行片段。 -
Click单击并and type your search string.
键入搜索字符串。
WebStorm will search for the target inside the selected fragment first.WebStorm将首先搜索所选片段内的目标。If you release如果释放, WebStorm will switch the search process back to the whole file.
,WebStorm将把搜索过程切换回整个文件。
If you want to search for the multi-line fragment itself, select it and press Ctrl+F.如果要搜索多行片段本身,请选择它并按Ctrl+F。
Manage your search管理您的搜索
-
To see the list of previous searches, press ⌥+↓ in the search field.要查看以前搜索的列表,请在搜索字段中按⌥+↓键。 -
To enter a multi-line string, click the要输入多行字符串,请单击搜索字段中的icon in the search field for a new line.
图标以查找新行。
-
With选中selected, WebStorm automatically escapes special regex symbols with backslash
\
when you search for a text string that contains them.选项后,当您搜索包含特殊正则表达式符号的文本字符串时,WebStorm会自动用反斜杠
\
转义这些符号。For more details on regex, refer to the search with regex documentation.有关regex的更多详细信息,请参阅使用regex搜索文档。 -
To navigate to the previous or to the next occurrence, use the要导航到上一个或下一个引用,请使用and
arrows.
和
箭头。
-
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.使用“查找”工具窗口中的Alt+F7引用列表,在该窗口中可以使用其他选项,例如,对结果进行分组或在单独的窗口中打开结果。 -
To add a selection of the next occurrence or deselect the previous occurrence, click要添加下一个引用的选择或取消选择上一个引用,请单击or
Alt+J or Alt+Shift+J.
或
,按Alt+J或Alt+Shift+J。
-
To quickly replace the target of your search in the whole file, press Ctrl+Alt+Shift+J and type the replacement string.要在整个文件中快速替换搜索目标,请按Ctrl+Alt+Shift+J并键入替换字符串。 -
To narrow your search, select the Words or Match case checkbox on the search pane, or click filter要缩小搜索范围,请在搜索窗格上选中“单词”或“匹配大小写”复选框,或单击“筛选”and select a scope for your search.
并选择搜索范围。
-
To quickly select or clear the Regex checkbox, press ⌥X (previously known as ⌥G).要快速选择或清除正则表达式复选框,请按⌥X(以前用⌥G)。Use regular expressions for more challenging searches.使用正则表达式进行更具挑战性的搜索。
Replace the search string in a file替换文件中的搜索字符串
-
Press Ctrl+R or select Replace in File window.按Ctrl+R或从主菜单中选择“编辑”|“查找”|“替换”以打开“在文件中替换”窗口。 from the main menu to open the -
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.“替换”窗口中显示的选项与“查找”窗口类似,您可以参考管理搜索结果部分。