---
title: Code viewer
description: Browse your code, search files, and add comments as context for your next prompt.
docs_index: /docs/llms.txt
lastUpdated: 2026-09-28
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 viewer lets you inspect the code v0 generates and point to specific lines when requesting changes. Open the **Code** tab in the preview toolbar to get started.

The viewer is read-only. To change code, describe what you want in the chat or add a comment to the relevant lines and send it with your next prompt.

## 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.

## 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. Click a line number, or drag across the gutter to select multiple lines.
2. Select the **+** button next to the selected lines to open the comment field.
3. Enter your comment, then select **+** in the comment field to add it to your prompt. You can also add selected lines without a comment.
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.

Commenting requires permission to write to the chat. An unfinished line 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. Select added or removed lines from one side of the diff and 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)