# Search and Replace

You can search the active document, the current project, or just the project filenames.

## Find in the active document

Press **Ctrl+F** and type your search text. *Lx* highlights matches while you type.

| Shortcut | Action |
| --- | --- |
| Enter | Move to the next match |
| Ctrl+Enter | Accept the current match and close the search box |
| Page Up | Move the document up while searching |
| Page Down | Move the document down while searching |
| Escape | Close Find |

After closing the search box, press **F3** for the next match or **Shift+F3** for the previous one.

If text is selected when you press **Ctrl+F**, *Lx* starts with that text.

## Replace text

Press **Ctrl+H** in an editable text document.

1. Enter the text to find.
2. Enter its replacement.
3. Press **Enter** to replace the current match and move to the next one.
4. Press **Escape** to close Replace.

You can undo replacements with **Ctrl+Z**.

## Closing Find and Replace

Find and Replace normally keep the last match selected when you close them.

Use these settings to change that behavior:

```lua
config.find_escape_clears_text = true
config.find_restore_position_on_exit = true
```

The first setting makes the first press of **Escape** clear non-empty search or replacement text. Press **Escape** again to close.

The second setting returns to the selection from before you opened Find or Replace.

## Search the project

Press **Ctrl+Shift+F** to search all files in the current project. The search is not case-sensitive.

The results open in their own tab:

| Key | Action |
| --- | --- |
| Up or Down | Select a result |
| Enter | Open the selected result |
| F5 | Search again |

## Find a file by name

Press **Ctrl+P** and type part of a filename. Choose a result and press **Enter** to open it.

Use the command palette with **Ctrl+Shift+P** for pattern search, fuzzy project search, and other search actions.
