CLion 2020.1 Help

Find and Replace in Project

You can search for occurrences and usages of targets within a project, and narrow your search by using different scopes and excluding certain items.

Find the search string in a project

  1. From the main menu, select Edit | Find | Find in Path 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. CLion places the highlighted string into the search field.

    To see a list of your previous searches, press Alt+Down.

    Find in path

    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.

  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.

  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.

Replace the search string in a project

  1. Press Ctrl+Shift+R to open the Replace in Path dialog.

  2. 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 Replace in Path instead of Rename refactoring since your variable can appear in config files as well.

  3. Click one of the available Replace commands.

You can use different options in the Find in Path 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.

  • With the Regex icon selected, CLion automatically escapes special regex symbols with backslash \ when you search for a text string that contains them.

    For more details on regex, refer to the search with regex documentation.

  • Click the filter icon to filter your search. 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 only to the open files in your project.

    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.

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 Path dialog, select the File Mask checkbox and from the list of file types, select the one you need.

    CLion limits its search to the specified type.

  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 cpp files: *.cpp.

    Besides *, other wildcards are supported. If necessary, specify several file types using commas as separators.

Last modified: 11 June 2020