Skip to content

Edit ops — undo/redo, the command palette & clipboard

tutorial lesson Beginner ⏱ 5 min vgai 0.1.0

Prerequisites: Take the editor tour

What you'll learn

  • Run any edit op from the command palette (⌘K)
  • Delete an entity and undo/redo the change
  • Know the full edit-op set and their shortcuts

What you'll build: Deleting an entity from the palette, then undoing and redoing it.

Walkthrough — Edit ops — undo/redo, the command palette & clipboard · generated by site/media/lessons/learn-editops.lesson.ts (4 steps)

Editing in vgai is safe to experiment with because every mutation is undoable — the store keeps a 50-deep undo stack. The fastest way to reach any action is the command palette (⌘K / Ctrl+K), which searches both editor actions and your entities.

  1. Select an entity and open the palette. With GoldSphere selected, ⌘K opens the palette and “Delete Selected” is one keystroke away — each action shows its shortcut (here Del).

    Command palette with Delete Selected
    ⌘K finds any edit op — and lists its shortcut.
  2. Delete it. Running the action removes GoldSphere from both the hierarchy and the viewport.

    Hierarchy after delete
    The entity is gone — hierarchy and scene update together.
  3. Undo. Undo (⌘Z on macOS, Ctrl+Z on Windows/Linux) restores the entity — it reappears in the tree and in the scene. Not sure of the key? Just run Undo from the palette (⌘K / Ctrl+K) — same action, no shortcut to remember.

    Entity restored after undo
    Undo brings it back from the 50-deep stack.
  4. Redo. Redo (⌘⇧Z on macOS, Ctrl+Shift+Z or Ctrl+Y on Windows/Linux — or run Redo from the palette) re-applies the delete. Undo/redo walk the same history in both directions.

Recap

New functionality

  • Ran Delete / Undo / Redo from the command palette
  • Saw an entity removed and restored in hierarchy + viewport

New concepts & skills

  • ⌘K opens a fuzzy palette over actions and entities (each shows its shortcut)
  • every mutation is undoable — a 50-deep stack walked by Undo/Redo
  • the edit-op set: copy/cut/paste, duplicate, delete, select-all/deselect, all on the selection

Next lesson → Editor architecture

On Your Own!

Extend what you built:

  • Select an entity, ⌘/Ctrl+C then ⌘/Ctrl+V — a duplicate appears
  • Make several edits, then ⌘/Ctrl+Z repeatedly to walk back through history
  • ⌘/Ctrl+A to select all, then move them together with the gizmo