> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polymet.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit code

> Open any file in your project, change it by hand, and save it as a new version.

The code editor shows every file in your project and lets you change them directly. Polymet checks your changes as you type and holds back **Save** while it finds errors.

Every plan can open and edit code. Downloading the code is a separate feature, see [Export your code](https://docs.polymet.ai/publish/export-code.md).

![The code editor with the file tree on the left and a component open in the editor](https://mintcdn.com/polymet/TfIzLh80_L4bW9xQ/images/docs/canvas/code-editor.png?fit=max\&auto=format\&n=TfIzLh80_L4bW9xQ\&q=85\&s=d08b9179e01e0489f47e80c5e859e035)

## Open a file

1. Click **Code** in the switch at the top left of the canvas (**Canvas**, **Focus**, **Code**, **Backend**).
2. Pick a file in the file tree on the left.

If you open a file in **Focus** that has no preview, such as a utility file, click **Open in Code**.

Some files, often prototypes, are drawn on the canvas by a second file. When that is the case, **Show render** and **Show source** appear above the editor to switch between the two.

## Change and save

1. Edit the file. You can change several files before saving.
2. **Save** and **Discard** appear at the top of the editor.
3. Click **Save**. A dialog lists every file you changed.
4. Click **Save** again to confirm.

The save becomes a new version in your project's history, so you can roll it back like any other.

**Discard** asks first, then throws away every unsaved change. It cannot be undone.

If you try to leave with unsaved changes, Polymet asks whether to discard them.

## Errors block Save

While you type, Polymet checks that your code is valid and, for files shown on the canvas, that they still build. Problems show in the **Errors** panel under the editor, marked **Syntax Error**, **Bundle Error** or **Error**, with the file and line.

**Save** stays off until they are fixed. Its tooltip says why:

| Tooltip | What to do |
| - | - |
| "Bundling in progress..." | Wait a moment. Polymet is checking your change |
| "Some files have errors" | Fix what the **Errors** panel lists |

An empty file counts as an error ("Code cannot be empty"). To remove a file, delete it from the file navigator instead.

## When the editor is read-only

Click into the editor to see why. The common reasons:

* A generation is running. Wait for it to finish.
* You have pending notes from [Select](https://docs.polymet.ai/canvas/select-and-edit.md). Send or remove them first.
* You have unsaved changes in the [visual editor](https://docs.polymet.ai/canvas/visual-editor.md). Save or discard them first.
* You are looking at an older version. Switch to the latest one to edit.
* The file is a plan. Plan files are read-only.

## Related

* [Edit visually](https://docs.polymet.ai/canvas/visual-editor.md) — change styles without touching code
* [Pages, components and files](https://docs.polymet.ai/canvas/files.md) — rename, delete and copy files
* [Export your code](https://docs.polymet.ai/publish/export-code.md) — download the project as a ZIP
* [Sync a project with a repository](https://docs.polymet.ai/github/sync.md) — edit in your own editor and keep both in step


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.