typst_find_and_replace
Find and replace text or regex in one Typst file or project-wide, using batch rules, dry-run previews and per-file saves.
Instructions
Find and replace text or regex in one file or project-wide. Use replacements to batch mappings (e.g. Sep → September, Oct → October) in one call with one save per file. Rules run sequentially; later rules see earlier results. Batch output defaults to compact summary; request output='diff' or 'full' for previews. Supports dryRun and per-file mutation serialization. Project-wide changes are not atomic across files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | Optional glob pattern to filter target files when searching project-wide (e.g. '*.typ') | |
| limit | No | Maximum number of replacements per file (default: replace all occurrences) | |
| regex | No | Whether pattern is a regular expression (default: false) | |
| dryRun | No | If true, returns unified diffs and match counts without saving changes (default: false) | |
| output | No | summary: counts and first changed line; diff: also display diff; full: also unified patch. Defaults to summary for batches, full for legacy pattern/replacement calls. Applies to dry runs too. | |
| pattern | No | Search pattern to replace (literal substring or regex) | |
| filePath | No | Optional file path/name (e.g. 'main.typ'). If omitted, searches and replaces across all text files in the project. | |
| projectId | Yes | The Typst project ID | |
| ignoreCase | No | Case-insensitive search (default: false) | |
| replacement | No | Replacement text (supports $1, $2 capture groups if regex is true) | |
| replacements | No | Ordered replacement rules instead of pattern/replacement. Each rule runs on the previous result. Set regex, ignoreCase, and limit per rule. All rules are validated before any writes; each changed file is saved once. | |
| preferWebSocket | No | Push real-time TextUpdate over /editing/v3 WebSocket before REST persistence (default: true) |