# Find and replace in 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](tutorial-finding-and-replacing-text-using-regular-expressions.html) in your search, and manage your search results.

Procedure: Find the search string in a file

1. Open your file in the editor.

2. Press `Ctrl+F` (Windows), `⌘ F` (macOS), `⌘ F` (IntelliJ IDEA Classic (macOS)), `⌘ F` (macOS System Shortcuts), `Ctrl+F` (XWin), `Ctrl+F` (GNOME), `Ctrl+F` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+F` (Sublime Text), `⌘ F` (Sublime Text (macOS)), `⌘ F` (Xcode), `Ctrl+F` (Visual Studio), `⌘ F` (Visual Studio (macOS)), `Ctrl+F` (ReSharper), `⌘ F` (ReSharper (macOS)), `Ctrl+F` (QtCreator), `⌘ F` (QtCreator (macOS)), `Ctrl+F` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+F` (Eclipse (macOS)) or select `Edit | Find | Find`  from the main menu.

> **Note:**
> If you want to extend the search of your target beyond the current file, press `Ctrl+Shift+F` (Windows), `⌘ ⇧ F` (macOS), `⌃ ⇧ F` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ F` (macOS System Shortcuts), `Ctrl+Shift+F` (XWin), `Ctrl+Shift+F` (GNOME), `Ctrl+Shift+F` (KDE), `Ctrl+Shift+F` (Emacs), `Ctrl+Shift+F` (Sublime Text), `⌘ ⇧ F` (Sublime Text (macOS)), `⌘ ⇧ F` (Xcode), `Ctrl+Shift+F` (Visual Studio), `⌘ ⇧ F` (Visual Studio (macOS)), `Ctrl+Shift+F` (ReSharper), `⌘ ⇧ F` (ReSharper (macOS)), `Ctrl+Shift+F` (QtCreator), `⌘ ⇧ F` (QtCreator (macOS)), `Ctrl+Shift+F` (NetBeans), `Ctrl+H` (Eclipse), `⌃ H` (Eclipse (macOS)). For more information, refer to [Find and replace in project](finding-and-replacing-text-in-project.html).

3. In the search field that opens, enter your search string. CLion highlights the results of your search in the file.  Alternatively, in the editor, highlight the string you want to find and press `Ctrl+F` (Windows), `⌘ F` (macOS), `⌘ F` (IntelliJ IDEA Classic (macOS)), `⌘ F` (macOS System Shortcuts), `Ctrl+F` (XWin), `Ctrl+F` (GNOME), `Ctrl+F` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+F` (Sublime Text), `⌘ F` (Sublime Text (macOS)), `⌘ F` (Xcode), `Ctrl+F` (Visual Studio), `⌘ F` (Visual Studio (macOS)), `Ctrl+F` (ReSharper), `⌘ F` (ReSharper (macOS)), `Ctrl+F` (QtCreator), `⌘ F` (QtCreator (macOS)), `Ctrl+F` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+F` (Eclipse (macOS)). CLion places the highlighted string into the search field.

![search string](https://resources.jetbrains.com/help/img/idea/2026.2/cl_searchinfile_occur.png)

> **Note:**
> Place the caret at any string in your file and press `Ctrl+F` (Windows), `⌘ F` (macOS), `⌘ F` (IntelliJ IDEA Classic (macOS)), `⌘ F` (macOS System Shortcuts), `Ctrl+F` (XWin), `Ctrl+F` (GNOME), `Ctrl+F` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+F` (Sublime Text), `⌘ F` (Sublime Text (macOS)), `⌘ F` (Xcode), `Ctrl+F` (Visual Studio), `⌘ F` (Visual Studio (macOS)), `Ctrl+F` (ReSharper), `⌘ F` (ReSharper (macOS)), `Ctrl+F` (QtCreator), `⌘ F` (QtCreator (macOS)), `Ctrl+F` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+F` (Eclipse (macOS)) to find its occurrencesor go to `Edit | Find | Next Occurrence of the Word at Caret` in the main menu.

Procedure: Find in selection

You can search for a text string inside a multi-line selection.

> **Note:**
> CLion handles replacing in multi-line selections the same way.

1. Select a multi-line fragment and press `Ctrl+F` (Windows), `⌘ F` (macOS), `⌘ F` (IntelliJ IDEA Classic (macOS)), `⌘ F` (macOS System Shortcuts), `Ctrl+F` (XWin), `Ctrl+F` (GNOME), `Ctrl+F` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+F` (Sublime Text), `⌘ F` (Sublime Text (macOS)), `⌘ F` (Xcode), `Ctrl+F` (Visual Studio), `⌘ F` (Visual Studio (macOS)), `Ctrl+F` (ReSharper), `⌘ F` (ReSharper (macOS)), `Ctrl+F` (QtCreator), `⌘ F` (QtCreator (macOS)), `Ctrl+F` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+F` (Eclipse (macOS)).

2. Click ![the Filter Search Results icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.filter.svg), set a tick next to Search In Selection  and type your search string. CLion will search for the target inside the selected fragment first.

![Find in selection](https://resources.jetbrains.com/help/img/idea/2026.2/cl_search_in_selection.png)

If you remove the tick next to Search In Selection, CLion 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` (Windows), `⌘ F` (macOS), `⌘ F` (IntelliJ IDEA Classic (macOS)), `⌘ F` (macOS System Shortcuts), `Ctrl+F` (XWin), `Ctrl+F` (GNOME), `Ctrl+F` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+F` (Sublime Text), `⌘ F` (Sublime Text (macOS)), `⌘ F` (Xcode), `Ctrl+F` (Visual Studio), `⌘ F` (Visual Studio (macOS)), `Ctrl+F` (ReSharper), `⌘ F` (ReSharper (macOS)), `Ctrl+F` (QtCreator), `⌘ F` (QtCreator (macOS)), `Ctrl+F` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+F` (Eclipse (macOS)).

![Search for a multi-line selection](https://resources.jetbrains.com/help/img/idea/2026.2/cl_search_for_selection.png)

Procedure: Manage your search

CLion lets you adjust your search process and perform various actions with the displayed search results.

* The editor automatically scrolls while you type a search query. To disable this behavior, click ![the More button](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.general.moreVertical.svg) and uncheck the Scroll to Results During Typing option.

* To see the list of previous searches, click the magnifier glass icon or press `⌥↓` in the search field.

![search history](https://resources.jetbrains.com/help/img/idea/2026.2/cl_search_history.png)

* If you want to enter a multi-line string, click the ![Enter a new line](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.searchNewLineHover.svg) icon in the search field for a new line.

* With ![the Regex icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.inline.regex.svg) selected, CLion automatically escapes special regex symbols with backslash `\` when you search for a text string that contains them.

> **Note:**
> Keep in mind that if you copy (`Ctrl+C` (Windows), `⌘ C` (macOS), `⌘ C` (IntelliJ IDEA Classic (macOS)), `⌘ C` (macOS System Shortcuts), `Ctrl+C` (XWin), `Ctrl+C` (GNOME), `Ctrl+C` (KDE), `Ctrl+Insert` (Emacs), `Ctrl+C` (Sublime Text), `⌘ C` (Sublime Text (macOS)), `⌘ C` (Xcode), `Ctrl+C` (Visual Studio), `⌘ C` (Visual Studio (macOS)), `Ctrl+C` (ReSharper), `⌘ C` (ReSharper (macOS)), `Ctrl+C` (QtCreator), `⌘ C` (QtCreator (macOS)), `Ctrl+C` (NetBeans), `Ctrl+C` (Eclipse), `⌘ C` (Eclipse (macOS))) the string first and then paste (`Ctrl+V` (Windows), `⌘ V` (macOS), `⌘ V` (IntelliJ IDEA Classic (macOS)), `⌘ V` (macOS System Shortcuts), `Ctrl+V` (XWin), `Ctrl+V` (GNOME), `Ctrl+V` (KDE), `Shift+Insert` (Emacs), `Ctrl+Shift+V` (Sublime Text), `⌘ ⇧ V` (Sublime Text (macOS)), `⌘ V` (Xcode), `Ctrl+V` (Visual Studio), `⌘ V` (Visual Studio (macOS)), `Ctrl+V` (ReSharper), `⌘ V` (ReSharper (macOS)), `Ctrl+V` (QtCreator), `⌘ V` (QtCreator (macOS)), `Ctrl+V` (NetBeans), `Ctrl+V` (Eclipse), `⌘ V` (Eclipse (macOS))) it in the search field, the regex symbols will not be taken into account.

For more information about regex, refer to the [search with regex](tutorial-finding-and-replacing-text-using-regular-expressions.html) documentation.

* Use the ![Previous occurrence](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.up.svg) and ![Next occurrence](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.down.svg) arrows to navigate to the previous or the next occurrence.

* Click ![the More button](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.general.moreVertical.svg) for Multiple Cursors selection options: to add a selection of the next occurrence (`Alt+J` (Windows), `⌃ G` (macOS), `⌃ G` (IntelliJ IDEA Classic (macOS)), `⌃ G` (macOS System Shortcuts), `Alt+J` (XWin), `Alt+J` (GNOME), `Alt+J` (KDE), `Alt+J` (Emacs), `Ctrl+D` (Sublime Text), `⌘ D` (Sublime Text (macOS)), `⌃ G` (Xcode), `Alt+Shift+.` (Visual Studio), `⌥ ⇧ .` (Visual Studio (macOS)), `Alt+Shift+.` (ReSharper), `⌥ ⇧ .` (ReSharper (macOS)), `Alt+J` (QtCreator), `Alt+J` (QtCreator (macOS)), `Alt+J` (NetBeans), `Alt+Y` (Eclipse), `⌃ G` (Eclipse (macOS))) or to deselect the previous occurrence (`Alt+Shift+J` (Windows), `⌃ ⇧ G` (macOS), `⌃ ⇧ G` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ G` (macOS System Shortcuts), `Alt+Shift+J` (XWin), `Alt+Shift+J` (GNOME), `Alt+Shift+J` (KDE), `Alt+Shift+J` (Emacs), `Alt+Shift+J` (Sublime Text), `⌃ ⇧ G` (Sublime Text (macOS)), `⌃ ⇧ G` (Xcode), `Alt+Shift+Comma` (Visual Studio), `⌥ ⇧ Comma` (Visual Studio (macOS)), `Alt+Shift+Comma` (ReSharper), `⌥ ⇧ Comma` (ReSharper (macOS)), `Alt+Shift+J` (QtCreator), `⌃ ⇧ G` (QtCreator (macOS)), `Alt+Shift+J` (NetBeans), `Alt+Shift+Y` (Eclipse), `⌃ ⇧ G` (Eclipse (macOS))).

* If you want to quickly replace the target of your search in the whole file, press `Ctrl+Alt+Shift+J` (Windows), `⌘ ⌃ G` (macOS), `⌘ ⌃ G` (IntelliJ IDEA Classic (macOS)), `⌘ ⌃ G` (macOS System Shortcuts), `Ctrl+Alt+Shift+J` (XWin), `Ctrl+Alt+Shift+J` (GNOME), `Ctrl+Alt+Shift+J` (KDE), `Ctrl+Alt+Shift+J` (Emacs), `Alt+F3` (Sublime Text), `⌘ ⌃ G` (Sublime Text (macOS)), `⌘ ⌃ G` (Xcode), `Alt+Shift+;` (Visual Studio), `⌥ ⇧ ;` (Visual Studio (macOS)), `Alt+Shift+;` (ReSharper), `⌥ ⇧ ;` (ReSharper (macOS)), `Ctrl+Alt+Shift+J` (QtCreator), `⌘ ⌃ G` (QtCreator (macOS)), `Ctrl+Alt+Shift+J` (NetBeans), `Ctrl+Alt+Y` (Eclipse), `⌘ ⌃ G` (Eclipse (macOS)) and type a new string.

![Replacing all occurrences](https://resources.jetbrains.com/help/img/idea/2026.2/cl_replace_text_in_file.animated.gif)

* You can narrow your search when you click ![the Words icon](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.inline.exactWords.svg), ![the Match case icon](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.inline.matchCase.svg) in the search field, or click ![the filter icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.filter.svg) to select a scope for your search.

* You can press `^⌥X` (previously known as `⌥G`) to quickly toggle ![the Regex icon](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.inline.regex.svg) the [Regex](regular-expressions.html) option. You can use [regular expressions](tutorial-finding-and-replacing-text-using-regular-expressions.html) to opt for more challenging searches.

* Press `Ctrl+F7` (Windows), `⌘ F7` (macOS), `⌘ F7` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ U` (macOS System Shortcuts), `Ctrl+F7` (XWin), `Ctrl+F7` (GNOME), `Ctrl+7` (KDE), `Ctrl+F7` (Emacs), `Ctrl+F7` (Sublime Text), `⌘ F7` (Sublime Text (macOS)), `⌘ F7` (Xcode), `Alt+Shift+F11` (Visual Studio), `⌥ ⇧ F11` (Visual Studio (macOS)), `Ctrl+Shift+F7` (ReSharper), `⌘ ⇧ F7` (ReSharper (macOS)), `Ctrl+F7` (QtCreator), `⌘ F7` (QtCreator (macOS)), `Ctrl+F7` (NetBeans), `Ctrl+Shift+G` (Eclipse), `⌘ ⇧ U` (Eclipse (macOS)) to see usages of any element in the opened file.

If you don't want CLion to highlight all found usages in the file, open

the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `⌘ Comma` (Xcode), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (ReSharper), `⌘ Comma` (ReSharper (macOS)), `Ctrl+Alt+S` (QtCreator), `⌘ Comma` (QtCreator (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))) and on the  `Editor | Code Editing` page, under the `Highlight on Caret Movement` section, clear the Usages of element at caret option.

Press `Alt+F7` (Windows), `⌥ F7` (macOS), `⌥ F7` (IntelliJ IDEA Classic (macOS)), `⌃ U` (macOS System Shortcuts), `Alt+F7` (XWin), `Alt+Shift+7` (GNOME), `Alt+Shift+7` (KDE), `Alt+F7` (Emacs), `Alt+F7` (Sublime Text), `⌥ F7` (Sublime Text (macOS)), `⌥ F7` (Xcode), `Shift+F12` (Visual Studio), `⇧ F12` (Visual Studio (macOS)), `Alt+F7` (ReSharper), `⌥ F7` (ReSharper (macOS)), `Ctrl+Shift+U` (QtCreator), `⌘ ⇧ U` (QtCreator (macOS)), `Alt+F7` (NetBeans), `Ctrl+G` (Eclipse), `⌘ ⇧ G` (Eclipse (macOS)) to [search for usages](find-highlight-usages.html) beyond the current file or `Ctrl+Alt+F7` (Windows), `⌘ ⌥ F7` (macOS), `⌘ ⌥ F7` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ U` (macOS System Shortcuts), `Ctrl+Alt+7` (XWin), `Ctrl+Alt+7` (GNOME), `Ctrl+Alt+7` (KDE), `Ctrl+Alt+F7` (Emacs), `Shift+F12` (Sublime Text), `⇧ F12` (Sublime Text (macOS)), `⌘ ⌥ F7` (Xcode), `Alt+Shift+F12` (Visual Studio), `⌥ ⇧ F12` (Visual Studio (macOS)), `Ctrl+Alt+F7` (ReSharper), `⌘ ⌥ F7` (ReSharper (macOS)), `Ctrl+Alt+F7` (QtCreator), `⌘ ⌥ F7` (QtCreator (macOS)), `Ctrl+Alt+F7` (NetBeans), `Ctrl+Alt+F7` (Eclipse), `⌘ ⌥ F7` (Eclipse (macOS)) to open the search results in a separate popup. If you need to configure some options before the search, press `Ctrl+Alt+Shift+F7` (Windows), `⌘ ⌥ ⇧ F7` (macOS), `⌘ ⌥ ⇧ F7` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ ⇧ U` (macOS System Shortcuts), `Ctrl+Alt+Shift+7` (XWin), `Ctrl+Alt+Shift+7` (GNOME), `Ctrl+Alt+Shift+7` (KDE), `Ctrl+Alt+Shift+F7` (Emacs), `Ctrl+Alt+Shift+F7` (Sublime Text), `⌘ ⌥ ⇧ F7` (Sublime Text (macOS)), `⌘ ⌥ ⇧ F7` (Xcode), `Ctrl+Alt+Shift+F12` (Visual Studio), `⌘ ⌥ ⇧ F12` (Visual Studio (macOS)), `Alt+Shift+F7` (ReSharper), `⌥ ⇧ F17` (ReSharper (macOS)), `Ctrl+Alt+Shift+F7` (QtCreator), `⌘ ⌥ ⇧ F7` (QtCreator (macOS)), `Ctrl+Alt+Shift+F7` (NetBeans), `Ctrl+Alt+Shift+F7` (Eclipse), `⌘ ⌥ ⇧ F7` (Eclipse (macOS)) to open the Find Usages dialog.

Procedure: Replace the search string in a file

1. Press `Ctrl+R` (Windows), `⌘ R` (macOS), `⌘ R` (IntelliJ IDEA Classic (macOS)), `⌘ R` (macOS System Shortcuts), `Ctrl+R` (XWin), `Ctrl+R` (GNOME), `Ctrl+R` (KDE), `Alt+Shift+5` (Emacs), `Ctrl+H` (Sublime Text), `⌘ ⌥ F` (Sublime Text (macOS)), `⌘ ⌥ F` (Xcode), `Ctrl+H` (Visual Studio), `⌃ H` (Visual Studio (macOS)), `Ctrl+H` (ReSharper), `⌃ H` (ReSharper (macOS)), `Ctrl+R` (QtCreator), `Ctrl+R` (QtCreator (macOS)), `Ctrl+H` (NetBeans), `Ctrl+F` (Eclipse), `Ctrl+R` (Eclipse (macOS)) or select `Edit | Find | Replace`  from the main menu to open the Replace in File window.

2. In the top field, enter your search string. In the bottom field, enter your replacement string. If you need to preserve the case, click ![the Preserve Case icon](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.inline.preserveCase.svg) located in the replace field.

![Replace search string in file](https://resources.jetbrains.com/help/img/idea/2026.2/cl_replace_searchstring_in_file.png)

Click ![Multi-line](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.searchNewLineHover.svg) 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.

3. 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](#work_with_search_results) section.

## See also

### Getting Started

[Editor basics](using-code-editor.html)  [Add, move, remove, copy lines and code blocks](working-with-source-code.html#editor_lines_code_blocks)

