WebStorm 2021.2 Help

Search for a target within a project在项目中搜索目标

You can search for text strings within a project and narrow your search by using different scopes and excluding certain items.您可以在项目中搜索文本字符串,并通过使用不同的范围和排除某些项来缩小搜索范围。

Find the search string in a project在项目中查找搜索字符串

  1. Press Ctrl+Shift+F or select Edit | Find | Find in Files from the main menu.Ctrl+Shift+F或从主菜单中选择“编辑”|“查找”|“在文件中查找”。

  2. In the search field, type your search string. 在搜索字段中,键入搜索字符串。Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F. 或者,在编辑器中,高亮显示要查找的字符串,然后按Ctrl+Shift+FWebStorm places the highlighted string into the search field.WebStorm将突出显示的字符串放入搜索字段。

    To see a list of your previous searches, press Alt+Down.要查看以前搜索的列表,请按Alt+Down

    If you need, specify the additional options.如果需要,请指定其他选项。

    Find in Files

    WebStorm lists the search strings and the files that contain them. WebStorm列出了搜索字符串和包含它们的文件。If the search string is found several times on the same line of code, WebStorm merges the results in one line.如果在同一行代码中多次找到搜索字符串,WebStorm会将结果合并到一行中。

    To do a multi-line search, click the Multi-line search icon to enter a new line, and press Ctrl+Alt+Down/ Ctrl+Alt+Up to browse through occurrences.要执行多行搜索,请单击Multi-line search图标以输入新行,然后按Ctrl+Alt+Down/Ctrl+Alt+Up浏览出现的内容。

  3. 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.在对话框的预览区域中检查结果,您可以在其中替换搜索字符串或选择其他字符串,再次按Ctrl+Shift+F并开始新的搜索。

  4. 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 Android studio icons logcat toolbar settings on the bottom of the Find in Files dialog and select the Open Results in New Tab checkbox.如果要在“查找”工具窗口中的单独选项卡中查看每个新搜索结果,请单击“在文件中查找”对话框底部的Android studio icons logcat toolbar settings,然后选中“在新选项卡中打开结果”复选框。

You can use different options in the Find in Files dialog to adjust your search process.您可以使用“在文件中查找”对话框中的不同选项来调整搜索过程。

  • Select options such as Words(the Words icon) or Match case(the Match case icon) to find the exact word in a project or match the letter case.选择“单词”(the Words icon)或“匹配大小写”(the Match case icon)等选项来查找项目中的确切单词或匹配字母大小写。

  • With the Regex icon selected, WebStorm automatically escapes special regex symbols with backslash \ when you search for a text string that contains them.选中the Regex icon后,当您搜索包含特殊正则表达式符号的文本字符串时,WebStorm会自动用反斜杠\转义这些符号。

    For more details on regex, refer to the search with regex documentation.有关正则表达式的更多详细信息,请参阅使用正则表达式搜索文档

  • Click the filter icon to filter your search. 单击filter图标以筛选您的搜索。For example, you can filter the search to omit comments or search only in comments instead.例如,您可以过滤搜索以忽略注释,或者改为仅在注释中搜索。

  • Select Directory to limit your search to a specific folder.选择“目录”以将搜索限制为特定的文件夹。

    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 to the scratch files in your project.例如,可以将搜索限制为项目中的临时文件。

    Limited search

    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 (ellipsis icon) to open the Scopes dialog.您也可以创建自己的自定义范围,单击“浏览”图标(ellipsis icon)打开“范围”对话框。

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.您可以从列表中选择现有文件类型、添加新文件类型或添加其他文件掩码语法以搜索具有特定模式的文件类型。

  1. In the Find in Files dialog, select the File Mask checkbox and from the list of file types, select the one you need.在“在文件中查找”对话框中,选中“文件掩码”复选框,然后从文件类型列表中选择所需的文件类型。

    File mask search

    WebStorm limits its search to the specified type.WebStorm将其搜索限制为指定的类型。

  2. 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 json files: *.json.例如,使用以下语法仅在json文件中搜索:*.json

    Besides *, other wildcards are supported. 除了*,还支持其他通配符If necessary, specify several file types using commas as separators.如有必要,请使用逗号作为分隔符指定几种文件类型。

    Add a new file type

Replace the search string in a project替换项目中的搜索字符串

  1. Press Ctrl+Shift+R to open the Replace in Path dialog.Ctrl+Shift+R打开“路径替换”对话框。

  2. In the top field, enter your search string. 在顶部字段中,输入搜索字符串。In the bottom field, enter your replacement string.在底部字段中,输入替换字符串。

    Replace in path dialog
  3. Click one of the available Replace commands.单击一个可用的替换命令。

Last modified: 15 June 2021