# Code editor

Edit code yourself in Machine Code, with language smarts, project search, and inline AI.

Canonical page: https://themachine.myapps.ai/docs/code/code-editor

Machine Code has a full code editor, so you can make your own changes next to
the agent's without switching apps.

## Open a file

- Click a file in **Files** (**Ctrl+Shift+E**).
- Press **Ctrl+P** and type part of a file name.
- Click a file name in an agent's reply.

![Searching files for order-form with Ctrl+P](/images/docs/code/file-search.webp)

The file opens in its own tab, with the project's files on the right.

![The code editor with order-form.ts open, type hints in the code, and the Problems bar at the bottom](/images/docs/code/editor.webp)

Save with **Ctrl+S** (**⌘S** on Mac).

## Language smarts

TypeScript and JavaScript work out of the box. For other languages, Machine
Code uses the language server already on your computer when it finds one, for
example `pyright` for Python, `gopls` for Go, or `rust-analyzer` for Rust.
For JSON, CSS, and HTML, install `vscode-langservers-extracted`.

| Key (Windows) | What it does |
|---|---|
| **F12** | Go to definition |
| **Shift+F12** | Find references |
| **F2** | Rename symbol |
| **Shift+Alt+F** | Format the file |
| **Ctrl+.** | Code actions, including **Quick fix...** on a problem |
| **Shift+Alt+O** | Organize imports |
| **Ctrl+Shift+O** | Go to a symbol in this file |
| **Ctrl+Alt+O** | Go to symbol in workspace |
| **Ctrl+Shift+F** | Search in files across the project |

On a Mac, use **⌘** for **Ctrl**. Problems and references open in a drawer
under the editor.

In the editor, **Ctrl+.** and **Ctrl+Shift+F** do the editor actions above.
Everywhere else they toggle both sidebars and focus mode.

## Inline AI

Press **Ctrl+K** (**⌘K** on Mac) inside the editor to ask for an edit right
where you are.

![The Edit with Machine box above the code, asking to reject pickup times less than 30 minutes away, with Generate edit, Fix, Explain, and Ask agent](/images/docs/code/inline-ai.webp)

| Action | What it does |
|---|---|
| **Generate edit** | Write an instruction, for example *make this function async*. The change shows as a diff you accept or reject. |
| **Fix** | Fixes the selected code, or the current line. |
| **Explain** | Explains the selected code, or the current line. |
| **Ask agent** | Sends the code and your question to a chat. |

While you type, the editor can also suggest the next few lines in grey.
Press **Tab** to accept a suggestion.

Inline AI uses Machine models and your Machine credits. To change it, open
**Settings › Inline AI**:

| Setting | What it does |
|---|---|
| **Completions while typing** | Turns the grey suggestions on or off. |
| **Typing pause** | How long you pause before a suggestion appears. |
| **Completion model** | The model for suggestions while you type. Pick a fast one. |
| **Edit model** | The model for Generate edit, Fix, and Explain. |

## Vim

Turn on **Vim keybindings** in **Settings › Editor**.
