find_and_replace
Replace text across all Markdown files in an Obsidian vault, with a dry-run mode to preview matches before committing changes.
Instructions
Find and replace text vault-wide across every .md file in the targeted vault. DESTRUCTIVE: this tool rewrites notes in-place. Run with dryRun: true first to preview matches; commit with dryRun: false. The vault SHOULD be in a clean git working tree (or otherwise backed up) before mutations — dry-run is the safety net. Concurrency posture is last-write-wins: if Obsidian (or a sync plugin) writes a note in the gap between the tool's read and write, the tool overwrites that external edit without warning. Close Obsidian or pause sync plugins before running mutations on important content. pathPrefix matching is case-sensitive on all platforms (including Windows) and is a directory-segment prefix (no glob expansion). Files in dot-prefixed directories (e.g., .obsidian/, .trash/) are excluded; the per-file size cap is 5 MB on both input and output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| regex | No | When true, `search` is parsed as an ECMAScript regex with flags g+i?+m+u (no s). | |
| dryRun | No | When true, no writes; the response includes structured per-match previews instead. | |
| search | Yes | The literal text or regex pattern to match. Required, non-empty. | |
| vaultId | No | Optional vault ID (defaults to configured default vault). | |
| verbose | No | When true, the response includes the per-file array. Default false to keep responses bounded for large vaults. | |
| wholeWord | No | When true, wraps the effective pattern in \b…\b (literal and regex modes). | |
| pathPrefix | No | If set, only files under this vault-relative path-prefix are scoped. Directory-segment match, case-sensitive on all platforms (including Windows), no glob expansion. Trailing slash is normalized away. | |
| replacement | Yes | The replacement text. Honors $1 / $& / etc. capture-group references when regex mode is on. | |
| caseSensitive | No | When false, matching is case-insensitive (ECMAScript Unicode case-folding). | |
| skipCodeBlocks | No | When true, fenced code blocks (CommonMark line-anchored, triple-backtick) are excluded from the search and preserved byte-for-byte. | |
| skipHtmlComments | No | When true, HTML comments (<!-- … -->) are excluded from the search and preserved byte-for-byte. Critical for preserving audit-trail comments during project-name renames. | |
| flexibleWhitespace | No | When true, substitutes any whitespace run in `search` with \s+. |