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

# Code Editor & Highlight-to-Ask AI (/docs/desktop/code-editor)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 539 · updated: 2026-11-11 -->
Related: [Desktop Workspace Overview](/docs/desktop/overview.md), [Agentic Canvas Mode](/docs/desktop/agentic-mode.md), [Multi-File Visual Diff Viewer](/docs/desktop/diff-viewer.md), [Transparency Dock & Approval Gates](/docs/desktop/transparency.md), [Integrated PTY Terminal](/docs/desktop/terminal.md)

> Code editing, syntax highlighting, and inline code selection actions in BhaiCode Desktop.

BhaiCode Desktop includes a responsive code editor powered by **CodeMirror 6**, paired with inline code selection actions.

***

## "Ask AI on Selection"

Highlight any lines of code in the editor to trigger the contextual action bar:

```text
┌─────────────────────────────────────────────────────────────┐
│ 42  export async function processPayment(orderId: string) { │
│ 43    const order = await db.order.findUnique({ ... });     │
│ 44    if (!order) throw new Error("Order not found");       │
│ 45 ┌──────────────────────────────────────────────────────┐ │
│ 46 │  const res = await dodoPayments.charges.create({     │ │
│ 47 │    amount: order.totalAmount, currency: "INR"        │ │
│ 48 │  });                                                 │ │
│    └──────────────────────────────────────────────────────┘ │
│       [ Ask AI ]  [ Explain ]  [ Refactor ]  [ Add Tests ]   │
└─────────────────────────────────────────────────────────────┘
```

### Available Actions

1. **Ask AI** (`Cmd + K` / `Ctrl + K`): Opens a contextual prompt attached directly to the highlighted code.
2. **Explain**: Explains the logic, time complexity, and edge cases of the selection in your preferred language (English, Hindi, etc.).
3. **Refactor**: Rewrites the snippet for readability, modern framework patterns, or performance.
4. **Add Unit Tests**: Generates unit tests matching your project's testing framework (Vitest, Jest, PyTest, Go test).
5. **Fix**: If a linter warning or compiler diagnostic is attached to the line, clicking **Fix** resolves it automatically.

***

## Editor Features

* **Language Support**: Syntax highlighting, bracket matching, and indentation for 100+ languages (TypeScript, JavaScript, Python, Rust, Go, SQL, HTML, CSS, JSON, YAML, Markdown).
* **Split Panes & Multi-Tab**: Open multiple files side-by-side to cross-reference implementations and tests.
* **Minimap & Breadcrumbs**: Navigate large files with a visual minimap and symbol breadcrumbs.
* **Find & Replace**: Regex-enabled project-wide search with case sensitivity toggles.
