Skip to content
Merged

X #217

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 138 additions & 36 deletions docs/05-Workspace/02-find-in-files.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,164 @@
---
slug: "/Features/find-in-files"
description: Use the magnifying glass in Phoenix Code to find words across your project, preview matching lines, and open the file you need. Includes folder and file-type filters.
toc_max_heading_level: 2
---

import TutorialIcon from '@site/src/components/TutorialIcon';
import TutorialVideo from '@site/src/components/Video/TutorialVideo';

# Find In Files

The Find in Files feature in Phoenix Code is a powerful tool to quickly search for specific text across multiple files within a project. This feature is useful for developers working on large codebases to find references, variable names, or specific lines of code.
Looking for a word on your website but unsure which file contains it? **Find in Files** searches the text in your project and takes you to the matching lines.

You'll open a project, search for some words, and open a file from the results. These steps work in **Community (free)** and **Phoenix Pro**.

## 1. Open your project

A **project** is the folder containing the files you are working on, such as your website's pages, pictures, and stylesheet.

**Need files to try this with?** [Download the optional practice website](/tutorials/first-website.zip) and extract the ZIP. Use its `first-website` folder in the next step.

If your project is already open, keep using it. Otherwise:

1. Click the <TutorialIcon name="startProject" label="folder with a plus sign" /> in the **top-left corner** of Phoenix Code. This opens the **Start Project** window.
2. Click **Open Folder**.
3. Select the folder containing your files and confirm the selection. For the practice website, select the extracted `first-website` folder.

You can also open a project through **File → Open Folder…**.

Check the folder name and files in the **sidebar**, the panel on the left. The screenshots below use a project named `first-website`; yours can have a different name.

If Live Preview fills the app, click its <TutorialIcon name="restore" label="restore icon" /> to show the editor and sidebar.

### Watch the walkthrough

The video starts with the project already open.

<TutorialVideo
metadata={{
name: 'Find text across project files in Phoenix Code',
description: 'Click the magnifying glass, search for Trail Notes in the first-website project, preview a matching line, and double-click it to open about.html at line 21 in this 24-second walkthrough.',
duration: 'PT24S',
dateCreated: '2026-11-11',
}}
poster="/tutorials/media/find-in-files-poster.png" width="1120" height="800" style={{width: '100%', height: 'auto'}} aria-label="24-second walkthrough: find text with the magnifying glass, preview a match, and open its file">
<source src="/tutorials/media/find-in-files.mp4" type="video/mp4" />
<track kind="captions" src="/tutorials/media/find-in-files.vtt" srcLang="en" label="English" />
<a href="/tutorials/media/find-in-files.mp4">Watch the Find in Files walkthrough</a>.
</TutorialVideo>

## 2. Click the magnifying glass {#use-the-magnifying-glass}

Look at the small toolbar **above the file list**. Click the <TutorialIcon name="search" label="magnifying glass" /> just to the right of the <TutorialIcon name="showInTree" label="binoculars" />. Hovering over the magnifying glass shows **Find in Files**.

![The first-website folder in the sidebar, with the magnifying glass at the top beside the binoculars](../images/find/magnifier-toolbar.png)

A search bar labeled **Find in project** opens above the code editor.

You can also choose **Find → Find in Files**, or press **Ctrl+Shift+F** on Windows/Linux or **Cmd+Shift+F** on macOS. Use the menu if your browser or operating system handles the shortcut instead.

## 3. Type the words you want to find

1. Click the search box under **Find in project**.
2. Type a word or phrase that appears in your files. This example searches for `Trail Notes`; use words from your own project.
3. For a search across the project, leave the filter on **No Files Excluded**. Leave **Regular Expression** (`.*`) off when searching for ordinary words.

[![The Find in project search bar with Trail Notes entered, the Aa and regular-expression buttons off, and No Files Excluded selected](../images/find/magnifier-search.png)](../images/find/magnifier-search.png)

**Search Results** appears at the bottom of the editor as you type. Drag the panel's top edge upward if you need more room.

To search across your project files, use `Ctrl-Shift-F` on Windows/Linux or `Cmd-Shift-F` on Mac, or select `Find > Find in Files` from the menu. This feature searches for your term throughout the project's files and displays each occurrence with its file name, line number, and a snippet of the code for context.
## 4. Preview a match and open its file

![Alt text](../images/find/fif.png)
A **match** is one place where your search text appears. The results group matches by filename and show the line number beside each matching line.

[![Search Results showing eight matches for Trail Notes across three files, with about.html line 21 selected and its code preview on the right](../images/find/magnifier-results.png)](../images/find/magnifier-results.png)

1. Find a filename in the results. Click its small **▸ triangle** if the matching lines are hidden.
2. **Click a matching line once** to preview its code on the right side of Search Results.
3. **Double-click the matching line** to open that file in the main code editor, with the matching words selected.

In this example, opening the paragraph match under `about.html` takes you to **line 21**. You have now found the file and the exact place containing your text. Searching and opening results leave the file contents unchanged.

Click either wide screenshot to view it full size.

## Need help?

<details>
<summary>Where is the magnifying glass if I can't see it?</summary>

If the sidebar is hidden, choose **View → Show Sidebar**. If Live Preview fills the app, click its <TutorialIcon name="restore" label="restore icon" /> first.

You can also open the search directly with **Find → Find in Files**.

</details>

<details>
<summary>What does the binoculars button do?</summary>

The <TutorialIcon name="showInTree" label="binoculars" /> is **Show in File Tree**: it locates the file you currently have open in the sidebar. Use the <TutorialIcon name="search" label="magnifying glass" /> to search for words inside your project files.

</details>

<details>
<summary>Why are there no results?</summary>

Check the project name on the left and try a word you can see in one of its files. Check spelling, spaces, and punctuation.

Turn off **Match Case** (`Aa`) to find both capital and lowercase letters. Leave **Regular Expression** (`.*`) off for ordinary text. These buttons appear highlighted when on.

To remove a file filter, open its dropdown and choose **Don't Exclude Files**. The button will read **No Files Excluded**. If you started a search in a subfolder, click the magnifying glass again to search the whole project.

</details>

<details>
<summary>How do I change the text I found?</summary>

Follow [Replace text in one file](/docs/tutorials/find-and-replace) to edit the open file, or [Replace text across files](/docs/tutorials/replace-in-files) to review and apply changes throughout a project.

</details>

## Searching Within a Folder

To search within a specific folder in Phoenix:
Once you're comfortable searching the whole project, you can narrow the search to one folder:

1. Right-click on the folder in the Files panel where you want to perform the search.
1. From the context menu that appears, select "Find in...".

![Alt text](../images/find/folder.png)
1. Right-click the folder in the sidebar's file list.
2. Choose **Find in…**.
3. Enter your search text. The search bar shows the selected folder, and results come from that folder and its subfolders.

3. The find bar will now appear with search restricted to that folder (See `in y/` in the below image).

![Alt text](../images/find/inFolder.png)
Click the <TutorialIcon name="search" label="magnifying glass" /> to return to a search across the whole project.

## Using File Filters

By default, Find in Files searches all files in your project folder. You can exclude or include files, file types, whole folders, or other patterns:

* Click the "No Files Excluded" dropdown from the search bar.
A **file filter** limits which files Phoenix Code searches. For example, you can search just your HTML pages or skip a folder.

![Alt text](../images/find/new-exclusion.png)
Open the **No Files Excluded** dropdown beside the search box:

Phoenix Code allows you to specify which files and folders should be excluded or included during project searches.
- Choose **Search in files** to search only files whose names or paths match your filter. Enter `*.html` to search HTML files, or `*.html,*.css` to search HTML and CSS files.
- Choose **Exclude files** to skip matching files. Enter `*.json` to skip JSON files.
- Choose **Don't Exclude Files** to clear the restriction.

### For searching only within files matching pattern
Enter the filter in the extra field that appears. Keep the words you want to find in the original search box.

When you select `Search in files` option from the above dropdown, the filter will search only within files and folders that match the entered patterns. Entering `*.json,*.css` will include only JSON and css files in your search results, or just enter `json` to select any files having charecters `json` in its path. See more patterns below.
### Search only matching files {#for-searching-only-within-files-matching-pattern}

![Alt text](../images/find/search_in_files.png)
With **Search in files** selected, `*.html` includes files such as `index.html` and `pages/about.html`. Plain text also works: `css` includes any file with `css` in its path, such as `styles.css` or `css/theme.txt`.

### For Excluding files
### Exclude matching files {#for-excluding-files}

When you select `Exclude files` option from the above dropdown, the filter will ignore files and folders that match the patterns you enter. For instance, typing `*.json` in the text area will exclude all JSON files from your search results. See more patterns below.
With **Exclude files** selected, the same patterns skip files instead. For example, `**/node_modules/**` skips files inside any folder named `node_modules`.

## The filter pattern

This section describes the format of the exclusion/search within files glob pattern.

1. Each pattern should be entered as a comma seperated text. You can specify multiple patterns:
```txt
*.js,*.json
```
1. To fuzzy search, just enter text. Eg. entering `css` will match all filenames that has the letters `css` in its path name like `x/st.css` and `cssFile.md`.
1. To match all JavaScript files in any directory, use `*.js`. This matches files like `a/b/x.js` and `xyz.js`.
1. To match JavaScript files only in the project root, use `./*.js`. This matches `x.js` in the root but not `y/x.js` in a subdirectory.
1. To match css files only in a folder `search/folder`, use `search/folder/*.css`. This matches `search/folder/x.css` but not `y/x.css`.
1. `?.js` will match only `a/b/x.js` and not `xyx.js`
1. `**/some_folder/**` will match `some_folder` anywhere.
1. `[]` to declare a range of characters to match (`example.[0-9]` to match on `example.0`, `example.1`, …)
1. To search for files names with `,` in it, use escape char `\`. Eg. To match a file with name `hello,world.js`, the filter string to use is `hello\,world.js`.
1. More complex glob patterns can be provided. See: https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns/
Patterns describe filenames or paths. Use them in either **Search in files** or **Exclude files**. Separate multiple patterns with commas, such as `*.js,*.json`.

| Pattern | Files it matches |
| --- | --- |
| `css` | Any path containing `css`, such as `styles.css` or `css/theme.txt`. |
| `*.js` | JavaScript files anywhere in the project. |
| `./*.js` | JavaScript files directly inside the project folder, excluding subfolders. |
| `search/folder/*.css` | CSS files directly inside a folder at a path ending in `search/folder`. |
| `?.js` | JavaScript files with a one-character name, such as `x.js`. |
| `**/some_folder/**` | Files inside a folder named `some_folder`, wherever it appears. |
| `example.[0-9]` | Files named `example.0` through `example.9`. |
| `hello\,world.js` | A filename containing a comma, `hello,world.js`. The backslash keeps the comma inside one pattern. |
93 changes: 93 additions & 0 deletions docs/10-Tutorials/06-find-and-replace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
title: Replace text in one file
slug: /tutorials/find-and-replace
description: Find and replace a word or phrase in the file you have open in Phoenix Code. Review each match, replace the text, and save your changes.
image: /tutorials/media/find-replace-one-file.png
toc_max_heading_level: 2
---

import TutorialIcon from '@site/src/components/TutorialIcon';
import TutorialVideo from '@site/src/components/Video/TutorialVideo';

Use **Find → Replace** to change a heading or correct a word in the file you have open. Enter the old text and the words you want to use in its place.

You'll open a file, find the text, replace it, and save. These steps work in **Community (free)** and **Phoenix Pro**.

## 1. Open your file

If Live Preview fills the app, click its <TutorialIcon name="restore" label="restore icon" /> to show the editor and sidebar, the file list on the left.

If the file you want to edit is already open, go to step 2. If its project is open, start at item 3 below.

**Need a sample file?** [Download the optional practice website](/tutorials/first-website.zip) and extract the ZIP. Use its `first-website` folder and `index.html` file in the steps below.

1. Click the <TutorialIcon name="startProject" label="folder with a plus sign" /> in the **top-left corner** of Phoenix Code. The **Start Project** window opens.
2. Click **Open Folder**, select the folder containing your files, and confirm. This folder is your **project**.
3. In the sidebar, **double-click the file** you want to change. Its contents open in the code editor. Check the filename above the code.

![The first-website project in the sidebar, with index.html selected and the folder-with-plus button at the top left](../images/find/magnifier-toolbar.png)

This example uses `index.html` in the `first-website` project. You can follow the steps with your own file.

### Watch the walkthrough {#watch-the-steps-in-26-seconds}

The video starts with the project already open.

<TutorialVideo
metadata={{
name: 'Find and replace text in one file in Phoenix Code',
description: 'Open index.html in the first-website project, use Find > Replace to change a heading, review the highlighted match, and save the file. A 26-second walkthrough using features available in Community and Pro.',
duration: 'PT26S',
dateCreated: '2026-11-10',
}}
poster="/tutorials/media/find-replace-one-file-poster.png" width="1120" height="800" style={{width: '100%', height: 'auto'}} aria-label="26-second walkthrough: find and replace a heading in one file">
<source src="/tutorials/media/find-replace-one-file.mp4" type="video/mp4" />
<track kind="captions" src="/tutorials/media/find-replace-one-file.vtt" srcLang="en" label="English" />
<a href="/tutorials/media/find-replace-one-file.mp4">Watch the single-file replacement walkthrough</a>.
</TutorialVideo>

## 2. Enter the old and new text

1. Open the **Find** menu at the top of the code editor and click **Replace**. Two text boxes appear above the code.
2. In **Find…**, enter the word or phrase you want to change. Use text that appears in this file.
3. In **Replace with…**, enter the new text.
4. Leave the **Regular Expression** (`.*`) button off for an ordinary text search.

[![Replace in index.html, with A little time outside. in Find, My weekend walks. in Replace with, and the original heading highlighted in the code](/tutorials/media/find-replace-one-file.png)](/tutorials/media/find-replace-one-file.png)

This example changes `A little time outside.` to `My weekend walks.` Use your own words when following the steps. Click the screenshot to view it full size.

A **match** is one place where the old text appears. Phoenix Code highlights a match in the editor and shows a count in the search box. **1 of 1** means it found one match in this file.

## 3. Replace and save

1. Check the highlighted match in the editor. Use the **◀** and **▶** buttons to move between matches.
2. Click **Replace** to change the highlighted match, or **Replace All** to change every match in this file.
3. Press **Esc** to close the search bar.
4. Choose **File → Save File**, or press **Ctrl+S** on Windows/Linux or **Cmd+S** on macOS.

**Check that the new text appears where you expected.** In the example, the heading in `index.html` should now read `My weekend walks.`

**Shortcut:** open Replace with **Ctrl+H** on Windows/Linux or **Cmd+Option+F** on macOS. Use **Find → Replace** if your browser or operating system handles the shortcut instead.

## Need help?

<details>
<summary>Why can't I find the text?</summary>

Check that the intended file is open. Copy the text directly from that file to avoid differences in spacing or punctuation.

Leave **Regular Expression** (`.*`) off. The **Match Case** (`Aa`) button makes capital and lowercase letters matter; turn it off if you want to find both.

If you don't know which file contains the text, first use [Find in Files](/docs/Features/find-in-files#use-the-magnifying-glass) to locate and open it.

</details>

<details>
<summary>How do I undo a replacement?</summary>

Choose **Edit → Undo** in the same file, check the result, then save again.

</details>

To change several files, follow [Replace text across files](/docs/tutorials/replace-in-files). To search across a project, see [Find in Files](/docs/Features/find-in-files).
Loading
Loading