Skip to content

Edit Code and Ask About a Selection

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

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.

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.

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.

ActionWhat it does
Ask AIOpens a prompt attached to the selection. Use it for a question or instruction that doesn’t fit a preset action.
ExplainDescribes the logic, time complexity, and edge cases in your preferred language, such as English or Hindi.
RefactorRewrites the selection for readability or performance, or to use a framework’s current conventions.
Add TestsGenerates unit tests for the project’s testing framework, such as Vitest, Jest, PyTest, or Go test.
FixApplies a fix when the line has an attached compiler diagnostic or linter warning.

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

Was this page helpful?