> ## Documentation Index
> Fetch the complete documentation index at: https://a5eb32f-docs-2.manicule.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://a5eb32f-docs-2.manicule.dev/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://a5eb32f-docs-2.manicule.dev/api/mcp.
> Every agent surface: https://a5eb32f-docs-2.manicule.dev/.well-known/llms-manifest.json

# Edit Code and Ask About a Selection (/desktop/code-editor)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 722 · updated: 2026-11-25 -->
Related: [Work in BhaiCode Desktop](/desktop/overview.md), [Delegate a Task in Agentic Canvas](/desktop/agentic-mode.md), [Review and Roll Back Agent Changes](/desktop/diff-viewer.md), [Run Commands in the Desktop Terminal](/desktop/terminal.md), [Review and Approve Agent Actions](/desktop/transparency.md), [Keyboard Shortcuts](/desktop/shortcuts.md)

> Navigate your project in CodeMirror 6 and ask Bhai about the lines you select.

Use the CodeMirror 6 editor to make a change yourself or ask Bhai for help with a specific block of code. Selecting lines opens a contextual action bar and gives **Ask AI** the selected code. Use the narrowest selection that still shows the behavior you want to explain, change, or test.

## Ask Bhai about a block of code

<Steps>
<Step title="Select the lines you want to discuss">Open the file and highlight the relevant lines. For example, select the part of a payment handler that looks up an order and handles a missing result if you want to discuss that failure path.</Step>

<Step title="Choose an action">Use the selection's action bar, or press `Ctrl + K` (`Cmd + K` on macOS) for **Ask AI**. The prompt opens with your selection attached, so you can ask about the code without pasting it into chat.</Step>

<Step title="Check the result against the selection">If you asked for an explanation, compare it with the branches you highlighted. If you asked for a refactor or tests, inspect the proposed changes and run the relevant check before keeping them.</Step>
</Steps>

| Action        | What it does                                                                                                     |
| ------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Ask AI**    | Opens a prompt attached to the selection. Use it for a question or instruction that doesn't fit a preset action. |
| **Explain**   | Describes the logic, time complexity, and edge cases in your preferred language, such as English or Hindi.       |
| **Refactor**  | Rewrites the selection for readability or performance, or to use a framework's current conventions.              |
| **Add Tests** | Generates unit tests for the project's testing framework, such as Vitest, Jest, PyTest, or Go test.              |
| **Fix**       | Applies a fix when the line has an attached compiler diagnostic or linter warning.                               |

## Navigate and compare files

CodeMirror 6 provides syntax highlighting, bracket matching, and indentation for more than 100 languages, including TypeScript, JavaScript, Python, Rust, Go, SQL, HTML, CSS, JSON, YAML, and Markdown.

Open files in tabs or split the editor to put an implementation next to its tests. In a long file, use the minimap to move across the file and symbol breadcrumbs to see where you are. Use project-wide **Find & Replace** when you need to search across files. Turn on regular expressions to match a pattern or use the case-sensitivity toggle to narrow the results.

## Next

* [Review proposed edits in the diff viewer](/desktop/diff-viewer)
* [Run checks in the integrated terminal](/desktop/terminal)
* [Find Desktop keyboard shortcuts](/desktop/shortcuts)
