Searching for text in files

You can search for text in files to quickly find and open files you need to work with. For example, to change the value for a product name variable, you can search for the variable in the source code files to identify files that need to be updated with the new value.

Keep the following in mind.

  • You can search using text phrases with or without wildcards or regular expressions. If you enter a phrase, the exact phrase is searched for.
    • If you enter a phrase with spaces, the entire phrase is searched for, not the individual words. For example, if you enter 'WysiCorp Products', only files that contain the exact phrase are returned. Files that contain only 'WysiCorp' or only 'Products' are not returned.
    • If you enter one search term, only files that contain the exact term are returned with only whole word matches. For example, if you enter 'WysiCorp', files that contain 'WysiCorp.h' or 'WysiCorporation' are not returned. Whole words are defined in the Unicode Standard Annex Word Boundaries. You can use wildcards for more flexible searching.
  • Only current file versions are searched. Historical file versions are not included in searches.
  • Text file results include the lines where a match was found. A maximum of 100 matching lines are returned per text file. For large text files, only the first 100,000 lines are searched. For long lines in text files, only the first 1,000 characters of the line are parsed. Matching lines are not included in the results for binary files. If the file type for binary files is changed to Text in the file properties, incorrect search results may be returned.
  • A message is displayed under the Location field if you select a branch that is not indexed, with indexing in progress, or with a corrupt index. You can continue the search, but it may take longer or return limited results. Indexing branches improves performance and search results. The Surround SCM administrator manages branch indexing. See Indexing branches for optimized searches.

1. Choose Edit > Find in Files.

The Find in Files window opens.

2. In the Search area, enter or select the Search Criteria.

  • Location specifies the branch and repository to search. If a repository is selected when the Find in Files window was opened, it is set as the location by default. Click the browse button to select a different location.
  • Do not use index searches without using the index if an indexed branch is selected. You may want to select this option if you are searching for punctuation and the results do not include files you expect them to. Keep in mind that non-indexed searches only include text files in the results and may be slower. See Differences between indexed and non-indexed searches for information about how indexed and non-indexed searches work.
  • Search for phrase specifies the text to search for. You can enter up to 128 characters. To include wildcards or regular expressions in the search, select the corresponding option in the Use list. If you choose to use regular expressions, this field changes to Search for regular expression.

Tip:  See Text search examples for examples using wildcards and regular expressions.

  • Recursive searches for the specified text in all files in the selected repository and all subrepositories.
  • Match case matches the exact case of the specified text. Only applies to text files. Binary file searches are always case insensitive. Case-sensitive searches may return results from binary and large text files that do not match the exact case of the specified text.
  • Search cloaked repositories also searches files in cloaked repositories. This option is selected if the search location is set to a cloaked repository. If this option is not selected, files in cloaked repositories are not searched.

3. Select any Refine Search options to further refine the search.

  • By extension only searches files with the specified file extensions. You can select extensions to include from the list or enter them. Separate multiple extensions with a comma. Select *.* to search all file extensions.
  • Exclude extensions excludes files with the specified file extensions. You can select extensions to exclude from the list or enter them. Separate multiple extensions with a comma.

Tip:  File extension lists are organized by groups. You can add file extensions to existing groups and create new groups to quickly select file types in searches. See Grouping file extensions to find related file types.

  • Limit results to specifies the maximum number of results to display. The default and minimum value is 50. This value only limits the number of results displayed, not the number of results found. If more results are found, the Show more results button is available in the Results area.

4. Click Search.

Files with content that matches the search criteria are displayed in the Results area. If you did an indexed search, a relevance value indicates how closely the results match the search criteria. Click Show more results to view additional results if the number to display is limited.

  • To narrow the results by filename, enter text in the Filename search field. Click the recent searches button to select a recently used filename. Click the clear filename cearch button to clear the filename search.
  • Expand a file to view all lines where the text was found. Click Expand All to expand all results or click Collapse All to collapse all expanded results.
  • To sort the results, click a column heading. A primary descending sort arrow or A primary descending sort arrow is displayed next to the heading. Shift+click a column heading to perform a secondary sort. A secondary ascending sort arrow or A secondary descending sort arrow is displayed next to the secondary sort heading. Click or Shift+click the column heading again to toggle the sort order.
  • To preview the text in file contents, select the file. The contents are displayed in the Preview area. If multiple results are found in the same file, click the next arrow button to go to the next match or the previous arrow button to go to the previous match.

Note:  You can only preview content for text files. To view content for a binary file, open it in the associated application.

  • To open a file, select it and click Open.
  • To go to the file in the source files list, select it and click Go To File.
  • To save the results list in HTML or CSV format, click Save As.

5. Click Reset to clear all options and perform a new search.

6. Click Close when you finish.

grep