bongho11k downloadsChange thousands of notes at once and undo it. Regex find and replace in one note, or search and replace in bulk across your vault: preview matches, pick files, revert the run. Multi-step pipelines.
Change thousands of notes at once in Obsidian and undo the whole run if it goes wrong. Regex find and replace with a preview of every match before anything is written.
Nothing is written until you have seen it. Scan the vault, review the matches file by file, untick what you did not mean, then revert the entire run with one command if the result is wrong. A file you edited since the scan is skipped rather than overwritten. Works for a one-off replacement or a saved multi-step cleanup for PDFs, AI-generated text, and Markdown.

| Capability | Obsidian's built-in replace | Regex Replace |
|---|---|---|
| Regular expressions and capture groups | — | ✓ |
| Before/after preview | — | ✓ |
| Match highlighting | — | ✓ |
| Replace within a selection | — | ✓ |
| Replace across the whole vault | — | ✓ |
| Undo an entire vault-wide run | — | ✓ |
| Skip files you edited since the scan | — | ✓ |
| Reusable multi-step cleanup pipelines | — | ✓ |
| Import regex-pipeline rulesets | — | ✓ |
Everything runs locally in your vault. The plugin does not send note content to external services.
$1, $2, etc.)\u, \l, \U, \L and \E in the replacement, as in sed and VS Codeg), case-insensitive (i), multiline (m), dot-matches-newline (s) and unicode (u) flagsCopy a search and replacement into Regex Replace, review the preview, and apply it only when the result is correct for your note.
| Cleanup | Search | Replace | Flags |
|---|---|---|---|
| Collapse repeated spaces | {2,} |
|
g |
| Remove trailing whitespace | [ \t]+$ |
(empty) | gm |
| Collapse 3+ blank lines | \n{3,} |
\n\n |
g |
| Change H2 headings to H3 | ^## |
### |
gm |
| Convert ISO dates to day/month/year | (\d{4})-(\d{2})-(\d{2}) |
$3/$2/$1 |
g |
| Remove Markdown bold markers | \*\*([^*]+)\*\* |
$1 |
g |
| Convert simple wiki links to Markdown links | `[[([^] | ]+)]]` | [$1]($1.md) |
[!CAUTION] A regular expression can match more text than intended. Check the highlighted preview before applying a replacement, especially with broad patterns.
Requires Obsidian 1.13.0 or later — the settings tab uses the declarative settings API introduced in that version, so its settings appear in Obsidian's settings search. Version 1.1.5 remains available for older releases.
main.js, manifest.json, and styles.css from the latest release<YourVault>/.obsidian/plugins/regex-replace/Cmd/Ctrl + Shift + HCmd/Ctrl + P → "Open Regex Replace"+--------------------------------------+
| Search pattern: \b(world)\b |
| Replace with: WORLD |
| |
| Flags: [x] g [ ] i [ ] m |
| [ ] Replace in selection only |
| |
| 2 match(es) found |
| |
| Preview |
| Before: Hello world, hello world |
| After: Hello WORLD, hello WORLD |
| |
| 2 match(es): |
| - "world" -> "WORLD" |
| |
| [ Replace all ] [ Cancel ] |
+--------------------------------------+
Before highlights every match in yellow, and After highlights each
replacement in green. Previously used patterns reappear in a Recent
patterns dropdown below the preview.
| Use Case | Search Pattern | Replace | Result |
|---|---|---|---|
| Find numbers | \d+ |
[NUM] |
abc123 → abc[NUM] |
| Date format | (\d{4})-(\d{2})-(\d{2}) |
$3/$2/$1 |
2024-12-08 → 08/12/2024 |
| Remove extra spaces | \s+ |
|
Multiple spaces → single |
| Wiki to MD link | \[\[(.+?)\]\] |
[$1]($1.md) |
[[Note]] → [Note](Note.md) |
| Header H2 → H3 | ^## |
### |
## Title → ### Title |
| Remove bold | \*\*(.+?)\*\* |
$1 |
**bold** → bold |
| Extract link text | \[(.+?)\]\((.+?)\) |
$1: $2 |
[text](url) → text: url |
| Flag | Name | Description |
|---|---|---|
g |
Global | Replace all matches (not just the first) |
i |
Ignore Case | Case-insensitive matching |
m |
Multiline | ^ and $ match line starts/ends |
Use parentheses () to capture groups and reference them with $1, $2, etc.:
Search: (\w+)@(\w+)\.com
Replace: User: $1, Domain: $2
Input: [email protected]
Output: User: test, Domain: example
The replacement understands the same case operators as sed, vim and VS Code.
\U and \L recase everything that follows until \E; \u and \l touch
only the next character.
Search: (- )([a-z])
Replace: $1\u$2
Flags: gm
Input: - element 1
Output: - Element 1
| Operator | Effect |
|---|---|
\u |
Uppercase the next character |
\l |
Lowercase the next character |
\U |
Uppercase everything until \E |
\L |
Lowercase everything until \E |
\E |
End the \U / \L span |
A ruleset is a named list of find/replace rules applied in sequence — each rule operates on the previous rule's output. Useful for repeatable, multi-step cleanups (e.g. normalize headers, then collapse whitespace, then fix links).
In Settings → Regex Replace → Pipeline rulesets, click Add ruleset, name it, and write rules using regex-pipeline syntax (one rule per block):
"SEARCH"->"REPLACE"
"\s+"->" "
"##\s"gm->"### "
"foo"gi->"bar"); without them, gm is used.Ruleset: <name> command, bindable
to a hotkey or a Commander / Editing Toolbar button.Turn on Apply to selection only — either on the ruleset itself in settings,
or with the checkbox in the pipeline dialog. Both write to the same stored
value, so the choice survives the next open and applies to the Ruleset: <name>
hotkey too.
When such a ruleset runs with nothing selected, it does nothing and shows a notice. It never falls back to the whole note, so a mis-fired hotkey cannot rewrite the file. Apply to selection only by default seeds the flag on newly added and imported rulesets, and rulesets saved before this option existed follow it until their own toggle is set.
Click Import from regex-pipeline to read every ruleset file in
<vault>/.obsidian/regex-rulesets/ and convert it into a native ruleset.
This ruleset removes trailing whitespace, reduces large blank gaps, and normalizes repeated spaces. Add it under Settings → Regex Replace → Pipeline rulesets, then preview it with Apply ruleset (pipeline).
"[ \\t]+$"gm->""
"\\n{3,}"g->"\\n\\n"
" {2,}"g->" "
Run Replace in vault from the command palette. Enter a pattern, flags, and a replacement, optionally limit it to a folder, then Scan vault.
The scan reads and matches in batches, so the progress count moves as it goes and you can cancel partway. When it finishes you get one row per file with a hit and its match count, all ticked. Untick the files you don't want; click a row to see that file's matches. Apply asks once more, naming how many files and roughly how long the write will take, and only replaces on the second click.

Undo last vault replace puts every file back. It keeps the last run only.
A file you edited after the replace is skipped rather than reverted, so an undo never overwrites work you did in between. The same check runs during apply: a file that changed between the scan and the write is skipped and reported.
--- block alone. Read from Obsidian's own
metadata, so a horizontal rule in the body is not mistaken for frontmatter.Archive, Templates/**,
**/*.excalidraw.md. A bare folder name covers everything under it. Hidden
folders are already skipped. This is separate from Obsidian's own
excluded-files setting, which plugins cannot read.(\w+\s?)+$ and friends —
cannot be interrupted on the thread running it, so matching happens in a worker
the main thread can terminate. Raise the timeout for a big vault, not for a
slow pattern.The vault commands were desktop-only in 1.2.2 while the worker that guards against a runaway pattern went unverified anywhere but the desktop. They run everywhere as of 1.3.0. The short version of why: backgrounding an app freezes the page, and a frozen page freezes its workers too, so the pattern stops when the watchdog does rather than burning on while nothing can kill it.
It is still the less-travelled path. If a scan ever seems to hang on a phone, lower Match timeout and report it.
Access via Settings → Regex Replace:
| Setting | Description | Default |
|---|---|---|
| Default Flags | Pre-selected regex flags (g, i, m, s, u) |
g |
| Show Preview | Display before/after preview | true |
| History Limit | Max saved patterns | 10 |
| Pipeline rulesets | Add/edit/delete/import reusable rulesets | — |
| Apply to selection only by default | Seeds the flag on new and imported rulesets | false |
| Vault scan: excluded paths | Glob list of paths to skip when scanning the vault | — |
| Vault scan: match timeout | Milliseconds a batch may match before the worker is killed | 2000 |
| Vault replace: warn above | File count past which the confirm step warns | 1000 |
# Clone the repository
git clone https://github.com/bongho/obsidian-regex-replace.git
# Install dependencies
npm install
# Build for development (watch mode)
npm run dev
# Build for production
npm run build
# Run tests
npx ts-node --transpile-only test.ts
s and u flags in the replace dialog. s lets . cross a line break, so a pattern can span a block; u turns on unicode mode, which is what \p{Ll} and friends need. Without them those patterns did not error, they just matched nothing or matched the literal characters\u, \l, \U, \L and \E work the way they do in sed, vim and VS Code, so a pattern can change the case of what it captured instead of only moving it around (#24)$` and $' now resolve in the preview. The preview dropped them silently, so it could disagree with what applying the replacement actually producedfundingUrl), so the plugin page in Obsidian shows a way to support the pluginnpm audit advisories (#22)src/ instead of keeping copies of it (#21)test.ts copies the functions it exercises out of src/, and two of the copies had fallen years behind — preview and execute were still the versions from before replacement unescaping and before the fix for lookaround in the match list. npm test now fails when a copy drifts (#19)isDesktopOnly stays false, so the rest of the plugin is unaffected (#18)npm test since it was added with no script behind it, so the 68 cases had only ever run by hand (#17)Ruleset: <name> commands, which previously always rewrote the whole notedisplay() fallback; the settings tab is declarative onlyminAppVersion to 1.13.0 — vaults below it stay on 1.1.5 via versions.jsondocument.createElement calls with Obsidian's createEl helperssrc/engine.ts0BSD License — see LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you find this plugin useful, consider:
Maintained by Bongho Lee, a Korean developer and AI researcher. Feedback, issues, and pull requests are welcome!
Made with ❤️ for the Obsidian community