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 editingBeta

Editor mode (experimental) makes any code surface—File or FileDiff—editable in place. Switch from Review (read-only) to Edit, then start typing in the code below and it updates as you edit. Select text to try the custom Selection Action widget.

Selection actions

Select any text to reveal the gutter icon, then click it to open a custom widget rendered with renderSelectionAction(). Run a transform on the selection—here, wrap a string for translation or shout it in caps—or drive the same wrap from the toolbar, then reset the surface to its original source.

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 with wavy underlines below to see an example.

Find in file

Open the search panel with Cmd/Ctrl-F on any File or FileDiff to find and replace. 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

Every edit lands on a structure-aware undo stack. The example below loads with a short refactor already applied across several commits—use the toolbar controls (or Cmd/Ctrl-Z and Shift to redo) to walk back and forth through each change.

0/7
  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
EnterNext match (in search panel)
EscClose the search panel
Multiple cursors
CmdClickAdd a cursor at the click

Everything else, at a glance

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, or MultiFileDiff; 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 tabs vs. spaces detected from the file.
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
Edit huge files with VirtualizedFile / VirtualizedFileDiff; off-screen lines render on demand.
Theme-aware
Edited lines re-highlight against the active light or dark theme automatically.
Background tokenizing
Re-highlighting is deferred during scroll and edit bursts to stay smooth.

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.