Typstyle

CLI Usage

Usage: typstyle [OPTIONS] [INPUT]...
Arguments:
[INPUT]...
List of files or directories to format [default: stdin]
Options:
-i, --inplace
Format the file in place
--check
Run in 'check' mode. Exits with 0 if input is formatted correctly. Exits with a non-zero status code if formatting is required
--diff
Run in 'diff' mode. Shows unified diff of what formatting changes would be made. Exits with 0 if input is formatted correctly. Exits with a non-zero status code if formatting is required
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Format Configuration:
-l, --line-width <LINE_WIDTH>
Maximum width of each line
[default: 80]
[aliases: -c, --column]
-t, --indent-width <INDENT_WIDTH>
Number of spaces per indentation level
[default: 2]
[alias: --tab-width]
--line-ending <LINE_ENDING>
Line-ending policy for formatted source output
Possible values:
- lf: Generate LF breaks, preserving literal source text
- crlf: Generate CRLF breaks, preserving literal source text
- preserve: Generate CRLF only when the input contains CRLF and no bare LF or CR
[default: preserve]
--no-reorder-import-items
Disable alphabetical reordering of import items
--wrap-text[=<WRAP_TEXT>]
Text wrapping mode: none (default), fill (wrap to line width), sentence (one per line), or fill-sentence (both)
Possible values:
- none: Do not wrap text (default)
- fill: Wrap text to fit within line width
- sentence: Place each sentence on its own line
- fill-sentence: Place each sentence on its own line, wrapping long sentences to the line width
[default: none]
Debug Options:
-a, --ast
Print the AST of the input file
-p, --pretty-doc
Print the pretty document
--timing
Show elapsed time taken by the formatter
Log Levels:
-v, --verbose
Enable verbose logging
-q, --quiet
Print diagnostics, but nothing else
Usage: typstyle [OPTIONS] [INPUT]...
Arguments:
[INPUT]...
List of files or directories to format [default: stdin]
Options:
-i, --inplace
Format the file in place
--check
Run in 'check' mode. Exits with 0 if input is formatted correctly. Exits with a non-zero status code if formatting is required
--diff
Run in 'diff' mode. Shows unified diff of what formatting changes would be made. Exits with 0 if input is formatted correctly. Exits with a non-zero status code if formatting is required
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Format Configuration:
-l, --line-width <LINE_WIDTH>
Maximum width of each line
[default: 80]
[aliases: -c, --column]
-t, --indent-width <INDENT_WIDTH>
Number of spaces per indentation level
[default: 2]
[alias: --tab-width]
--line-ending <LINE_ENDING>
Line-ending policy for formatted source output
Possible values:
- lf: Generate LF breaks, preserving literal source text
- crlf: Generate CRLF breaks, preserving literal source text
- preserve: Generate CRLF only when the input contains CRLF and no bare LF or CR
[default: preserve]
--no-reorder-import-items
Disable alphabetical reordering of import items
--wrap-text[=<WRAP_TEXT>]
Text wrapping mode: none (default), fill (wrap to line width), sentence (one per line), or fill-sentence (both)
Possible values:
- none: Do not wrap text (default)
- fill: Wrap text to fit within line width
- sentence: Place each sentence on its own line
- fill-sentence: Place each sentence on its own line, wrapping long sentences to the line width
[default: none]
Debug Options:
-a, --ast
Print the AST of the input file
-p, --pretty-doc
Print the pretty document
--timing
Show elapsed time taken by the formatter
Log Levels:
-v, --verbose
Enable verbose logging
-q, --quiet
Print diagnostics, but nothing else

Basic Usage

# Format multiple files
typstyle -i chapter1.typ chapter2.typ appendix.typ
# Format entire project
typstyle -i .
# Format with specific configuration
typstyle -l 100 -t 4 --wrap-text -i src/
# Format multiple files
typstyle -i chapter1.typ chapter2.typ appendix.typ
# Format entire project
typstyle -i .
# Format with specific configuration
typstyle -l 100 -t 4 --wrap-text -i src/

Arguments

Input Files

# Format from stdin (default)
cat file.typ | typstyle
# Format specific files
typstyle file1.typ file2.typ
# Format directories (recursively)
typstyle src/ docs/
# Format from stdin (default)
cat file.typ | typstyle
# Format specific files
typstyle file1.typ file2.typ
# Format directories (recursively)
typstyle src/ docs/

Main Options

Format Control

In-Place Formatting

# Modify files directly
typstyle -i file.typ
typstyle --inplace file.typ
# Modify files directly
typstyle -i file.typ
typstyle --inplace file.typ

Check Mode

# Exit with non-zero if formatting needed
typstyle --check src/
# Exit with non-zero if formatting needed
typstyle --check src/
# Like --check, but shows unified diff of what formatting changes would be made
typstyle --diff src/
# Like --check, but shows unified diff of what formatting changes would be made
typstyle --diff src/

Line Endings

The default preservepreserve policy retains consistent LF or CRLF conventions. Use lflf or crlfcrlf to force generated breaks:

# Force LF, including when checking in CI
typstyle --line-ending=lf file.typ
# Force CRLF
typstyle --line-ending=crlf --inplace file.typ
# Preserve the existing convention (the default)
typstyle --line-ending=preserve --inplace file.typ
# Force LF, including when checking in CI
typstyle --line-ending=lf file.typ
# Force CRLF
typstyle --line-ending=crlf --inplace file.typ
# Preserve the existing convention (the default)
typstyle --line-ending=preserve --inplace file.typ

preservepreserve generates CRLF only when the input contains at least one CRLF and no bare LF or bare CR. Mixed endings, bare CR, and inputs without newlines fall back to LF. Detection uses the whole original document, including for range formatting. All policies select generated layout breaks; newlines in strings, verbatim raw spans, and format-disabled source remain verbatim. Raw-block boundary breaks follow the layout policy. Diff control lines retain their normal LF output. The default --check--check accepts formatted CRLF files; use --line-ending=lf--line-ending=lf to enforce LF.

Format Configuration

Line Width

# Set maximum line width (default: 80)
typstyle -l 100 file.typ
typstyle --line-width 100 file.typ
# Set maximum line width (default: 80)
typstyle -l 100 file.typ
typstyle --line-width 100 file.typ

Indentation

# Set indentation width (default: 2)
typstyle -t 4 file.typ
typstyle --indent-width 4 file.typ
# Set indentation width (default: 2)
typstyle -t 4 file.typ
typstyle --indent-width 4 file.typ

Text Wrapping

# Wrap text in markup to fit line width (`--wrap-text` is shorthand)
typstyle --wrap-text file.typ
typstyle --wrap-text=fill file.typ
# Place each sentence on its own line
typstyle --wrap-text=sentence file.typ
# Place each sentence on its own line, and wrap long sentences to the line width
typstyle --wrap-text=fill-sentence file.typ
# Wrap text in markup to fit line width (`--wrap-text` is shorthand)
typstyle --wrap-text file.typ
typstyle --wrap-text=fill file.typ
# Place each sentence on its own line
typstyle --wrap-text=sentence file.typ
# Place each sentence on its own line, and wrap long sentences to the line width
typstyle --wrap-text=fill-sentence file.typ

Debug Options

AST Output

# Print the Abstract Syntax Tree
typstyle -a file.typ
typstyle --ast file.typ
# Print the Abstract Syntax Tree
typstyle -a file.typ
typstyle --ast file.typ

Pretty Document Output

# Print the internal pretty document representation
typstyle -p file.typ
typstyle --pretty-doc file.typ
# Print the internal pretty document representation
typstyle -p file.typ
typstyle --pretty-doc file.typ

Timing Information

# Show elapsed time taken by the formatter
typstyle --timing file.typ
# Show elapsed time taken by the formatter
typstyle --timing file.typ

Logging Options

See CLI help.