Beta

Edit files and diffs

Enable a full-featured yet lightweight editor that lazy-loads when needed on top of any File or FileDiff. All the ergonomics and customization of @pierre/diffs, with everything you need to edit in place.

Explore the docs

Live editing

Editor mode (experimental) makes any code surface—File or FileDiff—editable in place. Toggle between a read-only Review and a live Edit, switch the surface between a file and a diff, and render the diff unified or side-by-side split. Start typing in the code below and it updates as you edit.

Selection actions

Select any text to reveal a floating popover, anchored to the selection and rendered with renderSelectionAction(). Place any number of actions inside—here, an editor-style Add to chat sends the selected snippet to the panel on the right, while a secondary action copies it.

Annotate code with markers

Use editor.setMarkers() to inject inline context into your code for linter, formatting, and more. Includes support for severity-aware underlines and hover popups. Hover over markers (shown with wavy, colored underlines) in the example below.

Find and replace

Find strings across files with Cmd/Ctrl-F on any File or FileDiff. Find and replace with Cmd/Ctrl-Shift-F. The example below shows the search panel pre-filled—press Enter or use its arrows to jump between matches, and toggle case, whole-word, or regex as you go.

Undo history

Edits land on a structure-aware undo stack out of the box. Walk it with keyboard shortcuts and the toolbar below, or drive it in code with editor.undo(), editor.redo(), and editor.applyEdits(). The example loads with a short refactor already applied across several commits.

  1. Type the signature
  2. Declare the CartItem type
  3. Sum items with reduce
  4. Inline the discount
  5. Inline the shipping
  6. Add sales tax
  7. Round to cents

Keyboard shortcuts

Edit mode ships with all the additional shortcuts your users will need out of the box. Use the example File below to try the shortcuts you see in the table. Editing the example File will not update the table.

KeyAction
Editing
TabIndent line or selection
ShiftTabOutdent line or selection
CmdXCut
CmdCCopy
CmdVPaste
Selection & cursor
Move the cursor
ShiftExtend the selection
CmdJump to line start / end
CmdHomeEndJump to document start / end
CmdASelect all
EscCollapse to a single cursor
History
CmdZUndo
CmdShiftZRedo
Find
CmdFOpen the search panel
CmdDFind next match of the selection
CmdGNext match
CmdShiftGPrevious match
EnterNext match (in search panel)
EscClose the search panel
Multiple cursors
CmdClickAdd a cursor at the click

And everything else you need…

The demos above cover the headline features. Here's the rest of what edit mode gives you for free.

Editing

Files & diffs
Edit a File, FileDiff, MultiFileDiff, or PatchDiff; the new-file side of a diff re-tokenizes as you type.
Multiple cursors
Cmd/Ctrl-click adds carets; one edit applies to every selection and overlapping ranges merge.
Smart indentation
Indent or outdent whole selections, with tab vs. space inferred from each line's existing indentation.
International input
Compose CJK and other scripts, dictation, and emoji through the IME.

Rendering

Line wrapping
Carets, selections, and matches render correctly across wrapped visual lines.
Virtualized files
Use VirtualizedFile and VirtualizedFileDiff to edit massive files; off-screen lines render on demand.
Themes & color modes
Tokens and editor chrome follow the surface theme, re-tokenizing live when you switch themes or toggle light and dark.
UI adapts to container
Container queries reflow find & replace panel and marker popovers at narrow widths for a smoother experience, no matter the layout.

Integration & delivery

Diff annotations
Line annotations shift and survive edits and undo—the basis for agent/AUI surfaces.
SSR & hydration
Hydrate from prerendered, already-highlighted HTML with no flash.
Mobile & a11y
Native contentEditable with role="textbox"; autocorrect, spellcheck, and capitalization off.
Lazy-loadable
Standalone @pierre/diffs/editor entry point—import it only when editing begins.

With love from The Pierre Computer Company

Collectively, our team brings over 150 years of expertise designing, building, and scaling the world's largest distributed systems at Cloudflare, Coinbase, Discord, GitHub, Reddit, Stripe, X, and others.