lazytypst

Edit a Typst file in the terminal and see the page next to the text.

lazytypst lists the .typ files of a folder, opens one in an editor, and runs the typst command each time you pause. The compiled page and the errors stay on the same screen.

lazytypst in a terminal. On the left, the text of a Typst file with colored headings and math, and under it the compile pane that says OK in 297 ms. On the right, the compiled page with a heading, an equation, a list, and a table.
The editor with the colored source, the compile pane, and the preview of page 1. The status line shows the word count and the cursor position.

Start in three steps

  1. Install it. The program needs the typst command in PATH.
    cargo install --locked --git https://github.com/Orpheus-21/lazytypst
  2. Start it in a folder with Typst files.
    lazytypst ~/my-typst-folder
  3. Select a file with j and k, press Enter, and type. The preview follows the text. Press F1 to see all keys.

What it does

Browse
Lists the .typ files up to three folders deep. / filters the list, s sorts by the last change, and each line shows its age.
Edit
A text area with line numbers, wrapped lines, search, undo, and colors for headings, commands, strings, math, and comments. The status line shows an approximate word count.
Save
Saves 300 ms after your last key. It writes only when the text has edits, it refuses to overwrite a change that another program made, and it writes a temp file and renames it.
Compile
Runs typst compile after each save and shows the errors with their line numbers, the time, and the counts. A new compile stops the one that still runs.
Preview
Shows one page as an image, in the terminal. A page turn is one compile. The page of a book of 500 pages shows after 0.7 s in a release build. F11 fills the screen, and + and - zoom.
Main file
Mark a main file with m. The compile and the export then use it, whatever chapter you edit. Ctrl-G opens the file of the first error at the error.
Export
Ctrl-E writes the PDF next to the file, and Ctrl-O opens it. E in the list exports the selected file.

Install

With Cargo

cargo install --locked --git https://github.com/Orpheus-21/lazytypst

Cargo puts the program in ~/.cargo/bin. To update, run the command again.

On Arch Linux

The folder packaging/aur/ of the repository has a PKGBUILD for lazytypst-git. Run makepkg -si in it. The package is not on the AUR yet.

From a release

The releases page has a static binary for x86_64 Linux, its checksum file, and the man page. The first release is 0.1.0.

From a clone

git clone https://github.com/Orpheus-21/lazytypst.git
cd lazytypst
cargo build --release

All keys

This is the text of lazytypst --help, and the window that F1 opens. In that window, Enter on a line presses the key of that line.

Keys in the file list
? or F1Show this help window.
F9The mouse on or off. On: a click selects a file, a second click opens it, and the wheel moves the selection. The terminal cannot select by itself then: hold Shift and drag.
j or DownSelect the next file.
k or UpSelect the previous file.
EnterOpen the selected file.
nMake a new .typ file. Type a path such as chapters/two. The ending .typ is added.
EExport the PDF of the selected file next to it.
eEdit the selected file in $VISUAL or $EDITOR, then open it here.
sSwitch the order: by path, or the newest change first.
yCopy the absolute path of the selected file to the system clipboard.
/Filter the list. Type a part of a path. Enter keeps the filter, Esc removes it.
rRead the folder again, to show new files and to drop deleted files.
g or HomeSelect the first file.
G or EndSelect the last file.
mMark the selected file as the main file, or remove the mark. lazytypst then compiles the main file, whatever file you edit.
qQuit.
Keys in the editor
F1Show this help window.
F2Switch to another file. Type to filter, Enter opens. F2 again opens the file before this one.
Ctrl-SSave the file.
Ctrl-BSave and compile the file.
Ctrl-ESave the file and export a PDF next to it.
Ctrl-FSearch. Type the text, then Enter or Ctrl-F for the next match. Alt-R switches to a regular expression. Esc closes.
F11Show the preview on the full screen, and back. There, the plus key and the minus key zoom, 0 shows the whole page, and the arrow keys move the view. Typing does nothing there.
F5Turn the live compile off or on. Autosave stays on.
Ctrl-GGo to the first error of the last compile.
Alt-Enter, Ctrl-]Open the file that the string under the cursor names, for example in #include "chapters/two.typ". The text is saved first. F2 F2 goes back.
F3The preview follows the cursor, or not. When the cursor enters another section, the preview goes to the page of its heading. Alt-Up and Alt-Down still turn pages.
F6Show the history: the saved versions of this file, with their age and what they would change. Enter restores one as an edit, and Ctrl-Z undoes it. The versions are in the state folder, not in the project.
F7Spell check on or off. It needs hunspell and a dictionary. The language comes from #set text(lang: "de"). Unknown words are underlined.
Alt-;Go to the next misspelled word and show what to do: a suggestion, add the word to your dictionary, or ignore it.
F9The mouse on or off. On: a click puts the cursor there, a drag selects, the wheel scrolls the text, and the wheel over the preview turns pages. The terminal cannot select by itself then: hold Shift and drag.
Alt-LLoad the file from disk and drop the edits of the buffer. Your text goes to the history first (F6). Use it when the file changed on disk.
Alt-IInsert the image from the system clipboard: it is saved in the folder images of the project, and an #image line is put at the cursor. It needs wl-paste or xclip.
F10Change the layout: editor and preview side by side, editor above the preview, or editor only. A window under 100 columns starts stacked. The choice is kept.
F4Show the outline: the headings of the file. Type to filter, Enter jumps to the heading, F4 or Esc closes.
Alt-SReplace the text of the last search. Type the new text. Enter replaces one match and goes to the next. Alt-A replaces all. Esc stops. Press Alt-S in the search prompt, too.
Alt-GGo to a line. Type the line number, or line:column, then Enter. Esc closes.
F8, Shift-F8Go to the next error, or the previous error. The search wraps at the ends.
Ctrl-OOpen the last exported PDF in the system viewer (xdg-open).
Alt-DownShow the next page.
Alt-UpShow the previous page.
Alt-HomeShow the first page.
Alt-EndShow the last page.
EscSave the file and go back to the file list.
Ctrl-QSave the file and quit.
Editing keys in the editor
Ctrl-U, Ctrl-ZUndo.
Alt-ASelect all the text.
Ctrl-RRedo.
Shift with arrow keysSelect text.
Ctrl-CCopy the selection. It also goes to the system clipboard.
Ctrl-XCut the selection. It also goes to the system clipboard.
Ctrl-YPaste the text that the text area holds.
Shift-TabRemove one indent level from the line.
EnterBreak the line and keep its indent. After ( [ or { the new line has one level more.
Ctrl-WDelete the word before the cursor.
Ctrl-KDelete to the end of the line.
Ctrl-JDelete to the start of the line.
Alt-F, Alt-BMove one word forward or back.
Ctrl-A, EndMove to the start or the end of the line.
Ctrl-Home, Ctrl-EndMove to the start or the end of the file. With Shift, select to there.
Ctrl-V, Alt-VScroll one page down or up.
Alt-<, Alt->Move to the first or the last line. The column stays.

Limits

lazytypst edits one file at a time. It is not a file manager, a language server client, or a plugin host, and it has no completion. It does not replace the options of the Typst CLI with settings. See the scope in the README.

The tests run on Linux only. The sixel and iTerm2 protocols and terminals other than Ghostty are not tested.