# Search for a target within a file

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/llms.txt).

> **TL;DR**
> You can rename symbols, files, and all the references in your code with [the Rename refactoring](https://www.jetbrains.com/help/go/rename-refactorings.html.md) [Rename… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "RenameElement").

You can quickly find and replace text strings in the current document. Using different options, you can narrow your search process, use [regular expressions](https://www.jetbrains.com/help/go/tutorial-finding-and-replacing-text-using-regular-expressions.html.md) in your search, and manage your search results.

<a id="find_in_file"></a>

Procedure: Find the search string in a file

1. Open your file in the editor.

2. Press [Find… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Find") 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 [Find in Files… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "FindInPath"). For more information, refer to [Search and replace a target within a project](https://www.jetbrains.com/help/go/finding-and-replacing-text-in-project.html.md).

3. In the search field that opens, enter your search string. GoLand highlights the results of your search in the file.  Alternatively, in the editor, highlight the string you want to find and press [Find… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Find"). GoLand places the highlighted string into the search field.

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

> **Note:**
> Place the caret at any string in your file and press [Find… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Find") to find its occurrencesor go to `Edit | Find | Next Occurrence of the Word at Caret` in the main menu.

<a id="findInSelection"></a>

Procedure: Find in selection

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

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

1. Select a multi-line fragment and press [Find… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Find").

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

If you remove the tick next to Search In Selection, GoLand 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 [Find… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Find").

![find_in_selection](https://resources.jetbrains.com/help/img/idea/2026.3/go_find_in_selection.png)

<a id="work_with_search_results"></a>

Procedure: Manage your search

GoLand 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.3/app-client.expui.general.moreVertical.svg) and uncheck the Scroll to Results During Typing option.

* If you want to see the list of previous searches, press `⌥↓` in the search field.

![search history](https://resources.jetbrains.com/help/img/idea/2026.3/go_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.3/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.3/app.expui.inline.regex.svg) selected, GoLand 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 ([Copy shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "$Copy")) the string first and then paste ([Paste shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "$Paste")) it in the search field, the regex symbols will not be taken into account.

![Escape regex symbols](https://resources.jetbrains.com/help/img/idea/2026.3/go_escape_regex_symbols.png)

For more information about regex, refer to the [search with regex](https://www.jetbrains.com/help/go/tutorial-finding-and-replacing-text-using-regular-expressions.html.md) documentation.

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

* Work with the list of occurrences [Find Usages shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "FindUsages") in the Find tool window, where you have other options, for example, to group your results or to open them in a separate window.

![Found Occurrences in the Find tool window](https://resources.jetbrains.com/help/img/idea/2026.3/go_find_all_occurrences.png)

* Click ![the More button](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.general.moreVertical.svg) for Multiple Cursors selection options: to add a selection of the next occurrence ([Add Selection for Next Occurrence shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "SelectNextOccurrence")) or to deselect the previous occurrence ([Unselect Occurrence shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "UnselectPreviousOccurrence")).

* If you want to quickly replace the target of your search in the whole file, press [Select All Occurrences shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "SelectAllOccurrences") and type a new string.

![replace_text_in_file](https://resources.jetbrains.com/help/img/idea/2026.3/go_replace_text_in_file.png)

* You can narrow your search when you click ![the Words icon](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.inline.exactWords.svg), ![the Match case icon](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.inline.matchCase.svg) in the search field, or click ![the filter icon](https://resources.jetbrains.com/help/img/idea/2026.3/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.3/app.expui.inline.regex.svg) the [Regex](https://www.jetbrains.com/help/go/regular-expression-syntax-reference.html.md) option. You can use [regular expressions](https://www.jetbrains.com/help/go/tutorial-finding-and-replacing-text-using-regular-expressions.html.md) to opt for more challenging searches.

* Press [Find Usages in File shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "FindUsagesInFile") to see usages of any element in the opened file.

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

the Settings dialog ([Settings… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ShowSettings")) and on the `Editor | Code Editing` page, under the `Highlight on Caret Movement` section, clear the Usages of element at caret option.

Press [Find Usages shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "FindUsages") to [search for usages](https://www.jetbrains.com/help/go/find-highlight-usages.html.md) beyond the current file or [Show Usages shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ShowUsages") to open the search results in a separate popup. If you need to configure some options before the search, press [Find Usages Settings… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "ShowSettingsAndFindUsages") to open the Find Usages dialog.

<a id="replace_search_string"></a>

Procedure: Replace the search string in a file

1. Press [Replace… shortcut](https://www.jetbrains.com/help/go/llms-keymap-index.md "Replace") 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.3/app-client.expui.inline.preserveCase.svg) located in the replace field.

![Replace in file pane](https://resources.jetbrains.com/help/img/idea/2026.3/replace_in_file.png)

Click ![Multi-line](https://resources.jetbrains.com/help/img/idea/2026.3/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](https://www.jetbrains.com/help/go/using-code-editor.html.md)  [Add, move, remove, copy lines and code blocks](https://www.jetbrains.com/help/go/working-with-source-code.html.md#editor_lines_code_blocks)

