The CalcMark Editor

A terminal-based editor with live results, markdown preview, autocomplete, and keyboard-driven workflows.

The CalcMark editor is a terminal UI (TUI) that runs entirely in your terminal. You write CalcMark on the left, and results appear on the right — instantly, as you type.

cm                    # New document
cm budget.cm          # Open existing file
cm remote <url>       # Open a remote document
CalcMark editor showing recipe scaling with Results preview

Preview Modes #

The right pane has three modes. Press Ctrl+P to cycle through them:

Results #

The default mode. Shows calculation results aligned with their source lines. Markdown lines are blank on the right — you only see what CalcMark computed.

Results mode — calculation results aligned with source lines

Side-by-Side #

Shows rendered markdown alongside calculation results. Headings, lists, and prose are styled with terminal colors. This is useful when your document mixes explanatory text with calculations and you want to see both.

Side-by-Side mode — rendered markdown next to results

Reading Mode #

A full-document reading view. Markdown is rendered with styled headings, lists, and emphasis. Calculation results appear inline where the expressions are. Template variables (double-brace syntax) are resolved to their computed values.

Reading Mode has its own scroll position — you can scroll the preview independently of the source. Navigation jumps between sections: each heading, paragraph, list, and calculation is a stop.

Reading Mode — full rendered document with results inline

Keyboard Shortcuts #

Press Ctrl+H or F1 to open the help overlay. It lists every shortcut and lets you execute commands directly — highlight an action and press Enter.

Help overlay showing all keyboard shortcuts

File Operations #

ShortcutAction
Ctrl+SSave
Ctrl+NNew document
Ctrl+OOpen file (file picker)
Ctrl+TExport to Markdown, JSON, or HTML
Ctrl+QQuit

Editing #

ShortcutAction
Ctrl+Z / ⌘ZUndo
Ctrl+Y / ⌘⇧ZRedo
Ctrl+KDelete line
Ctrl+FInsert frontmatter template
Ctrl+C / ⌘CCopy selection
Ctrl+X / ⌘XCut selection
Ctrl+V / ⌘VPaste
⌘ASelect all
ShortcutAction
↑ ↓Move cursor up/down
← →Move cursor left/right
Opt+← / Opt+BWord left
Opt+→ / Opt+FWord right
⌘← / Ctrl+A / HomeLine start
⌘→ / Ctrl+E / EndLine end
PgUp / PgDnPage up/down
⌘↑ / Opt+↑Document start
⌘↓ / Opt+↓Document end

View #

ShortcutAction
Ctrl+PCycle preview mode (Results → Side-by-Side → Reading Mode)
Ctrl+H / F1Toggle help overlay
EscClose any overlay or popup

Autocomplete #

Start typing a function name, unit, or variable — after two characters, a popup appears with matching suggestions. Each suggestion shows a category tag:

  • fn — Built-in functions (compound, throughput, read, etc.)
  • nl — Natural language syntax examples
  • var — Variables defined earlier in your document

Use Tab or to select a suggestion, Enter to insert it, Esc to dismiss.

The context footer (below the editor) shows parameter help when your cursor is inside a function call. It displays the expected parameter name and example values for the argument you’re currently typing.

File Picker #

Ctrl+O opens a file browser overlay. Navigate directories with arrow keys, press to go up a directory, and Enter to open a .cm file. Press Tab to switch focus to the filename field where you can type a name directly.

The same picker appears for Save As and Export, with context-appropriate titles and hints.

Export #

Ctrl+T opens the export dialog. Choose a format:

  • Markdown (.md) — Rendered markdown with results inline
  • JSON (.json) — Structured output with values, types, and units
  • HTML (.html) — Styled HTML document

Pick a destination directory and filename, then press Enter to export.

The bottom of the editor shows context-sensitive information:

  • Variable references — When your cursor is on a calculation line, the footer shows the current values of variables referenced in that expression.
  • Error diagnostics — When a line has a parse or evaluation error, the footer shows the error message and a hint for fixing it.
  • Function parameter help — When typing inside a function call, the footer shows the parameter name and example values.
  • Autocomplete details — When the autocomplete popup is open, the footer shows the full description of the selected suggestion.

Status Bar #

The status bar at the bottom shows:

  • Current filename (or [New] for unsaved documents)
  • [+] indicator when the document has unsaved changes
  • Cursor position (L5:12) and calc block count
  • Selection character count when text is selected
  • EVAL... indicator during evaluation
  • Save confirmation and error messages

Color Modes #

CalcMark detects your terminal’s color scheme automatically. Override it with:

cm --color-mode dark    # Force dark mode
cm --color-mode light   # Force light mode

Or set it permanently in your configuration file.