hard

Design a Text Editor with Undo/Redo

Design a text editor with full undo and redo support. Include insert, delete, and replace operations as commands, a command history stack, cursor management, and macro command support.

Suggested time: 45 minutes

Loading the workspace...

About this problem

A text editor with undo/redo is one of the richest OOD problems because it forces you to think about reversible operations, command composition, and state consistency. Before writing any classes, let's define exactly what the system must support.

What your design needs to cover

  • Insert, Delete, and Replace Text

  • Undo and Redo Operations

  • Cursor Navigation and Position Tracking

  • Macro Commands

Key challenges the editorial covers

Learn from other designs

Related problems

Guides