External Editor Example

External Editor

Demonstrates temporarily exiting the TUI to invoke an external editor, then seamlessly re-entering—like editing a commit message in lazygit or tig.

Most applications use RatatuiRuby.run { } which handles terminal setup and teardown automatically. But some workflows require repeatedly leaving and re-entering raw mode during a single session. This example shows the low-level lifecycle API that makes this possible.

Features Demonstrated

Hotkeys

Key Action
/ or j/k Scroll one line
PgUp/PgDn Scroll one page
Home/End Jump to top/bottom
Mouse wheel Scroll hovered pane
Tab or / or h/l Switch focus between panes
e Edit this README.md in $EDITOR
s Edit scratch file; saved content appears in split pane
q Quit

Usage

ruby examples/app_external_editor/app.rb

Press e to edit this README. Press s to open a scratch file—when you save content, it appears beside the README in a split view.

Learning Outcomes

Use this example if you need to…

Read the source code →