---
title: Code viewer
description: Browse and edit your code, review changes, and add comments as context for your next prompt.
docs_index: /docs/llms.txt
lastUpdated: 2026-10-19
product: v0
type: guide
prerequisites:
  - /docs/quickstart
related:
  - /docs/text-prompting
  - /docs/design-mode
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

The **Code** tab lets you browse your project, make manual edits, and share specific code as context for your next prompt. Open it from the preview toolbar to get started.

## Browse files

Select a file from the file tree to view its contents with syntax highlighting and line numbers. The viewer updates as workspace changes become available.

Image files open as previews. Switching between Code and other tabs preserves your selected file and editor state within the same workspace session.

Use **Copy file contents** or **Download file** at the right of the file header to copy text or download the open file. For text files, both use the current editor contents, including pending edits. Images and other binary files can be downloaded.

## Manage files and folders

Right-click a file or folder in the tree to select **New file**, **New folder**, **Rename**, or **Delete**. You can also use the **New file** and **New folder** buttons above the tree.

New items are created inside the selected folder, or alongside the selected file. With no selection, the header buttons create items at the project root. Type the name directly in the tree, then press **Enter** or click away to confirm. Press **Escape** to cancel.

Rename also uses an inline name field. Delete asks for confirmation; deleting a folder removes its contents too.

File actions update the workspace immediately. Use **Save** to persist them or **Discard** to undo pending workspace changes. Empty folders are not persisted until they contain a file.

## Edit code

Select an existing text file or one you created in the file tree and start typing in the editor. Manual editing requires edit access to the chat and supports UTF-8 text files up to 1 MB. Images and other binary files remain read-only.

Edits automatically sync to your workspace after a short pause in typing. This updates the workspace files without committing them. Use the **Unsaved Changes** bar to:

- **Save**: Commit and persist pending changes to tracked workspace files, including files created, renamed, or deleted through the file tree. You can also press **⌘S** on macOS or **Ctrl+S** on Windows and Linux while focused in the editor.
- **Discard**: Restore all tracked workspace files to their latest committed version, remove files created through the editor, and clear pending editor drafts. Unrelated untracked files are left unchanged.

The editor supports undo and redo. Manual editing pauses while the agent is working.

Sending a prompt also attempts to sync pending edits, so the agent can continue from your workspace files. An editor synchronization failure does not prevent you from sending a prompt.

## Search code

Select the search icon above the file tree to show or hide the search field. Search matches both filenames and file contents.

Select a result to open the file. Content matches take you to the matching line. You can also use the arrow keys while focused in the search field to select results.

## Add code comments

Use comments to give v0 precise context for a change:

1. Select code in the editor.
2. Select **Add to chat** to open the comment field.
3. Enter an optional comment, then select **+** in the comment field to add the code and comment to your prompt.
4. Add any other instructions in the chat input and send your prompt.

Adding a comment does not send a message automatically. The prompt includes the file path, selected lines, captured code, and your comment. This preserves the code you were referring to even if the file changes later.

You can edit a saved comment using its pencil icon, or remove it from the prompt's annotation list before sending. Selecting a code annotation in that list opens its file in the Code tab.

In read-only code views, click a line number or drag across the gutter to select lines, then use **+** to add context.

Adding comments requires edit access to the chat. An unfinished selection or comment is cleared when you switch files or the displayed revision changes; comments already added to the prompt are retained.

## Review changes

Open a message's **Diff** tab to review the changes made in that version. The Diff tab is read-only. Click or drag across line numbers on one side of the diff, then use **+** to add a comment as context for your next prompt.

## Workspace loading

If the workspace needs to reconnect, the Code tab shows its connection status. During a background refresh, previously loaded content can remain visible. If loading fails, use **Retry** to try again.

---

For a semantic overview of all documentation, see [/docs/sitemap.md](/docs/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/docs/agents.md](/docs/agents.md)