edit_note
Edit Obsidian notes with six modes: append, prepend, replace window, patch heading, patch frontmatter, or at-line. Apply multiple edits atomically in one call.
Instructions
Modify an existing note. Supports six edit modes: append (add to end; defensively inserts a leading newline if the source didn't end with one), prepend (insert after frontmatter if present, otherwise at file start), replace_window (find a block of text and replace it — optionally fuzzy; fuzzy extends match to consume trailing .?! so the replacement has no doubled punctuation), patch_heading (insert or replace content under a specific heading; headingOp: 'before' | 'after' inserts immediately before/after the heading line — use before on the NEXT heading to append to a section's end; headingOp: 'replace' with scope: 'section' (default) replaces to the next same-or-higher heading or EOF — CAREFUL on the LAST heading, this consumes everything below including content separated by blank lines — pass scope: 'body' to stop at the first blank line after the body; if the target heading text appears MORE THAN ONCE the call throws MultipleMatches listing each occurrence with its line number — pass headingIndex: 0 | 1 | ... (0-indexed, top-to-bottom) to pick one), patch_frontmatter (set a single YAML key; pass value: null to clear — or from XML-stringifying clients use valueJson: 'null' for true null, valueJson: 'true' for a real boolean, valueJson: '42' for a number, valueJson: '["a"]' for an array; valueJson wins over value when both are set), at_line (insert or replace at a 1-indexed line number that counts from file start including frontmatter lines). Pass edits (array) to apply multiple edits atomically — all succeed or none are written.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Path or fuzzy match of the note to edit. | |
| mode | No | Edit mode. Required unless `edits` array is provided. | |
| content | No | New content to insert or replace (meaning is mode-dependent). | |
| search | No | For `replace_window`: the block of text to locate and replace. | |
| fuzzy | No | For `replace_window`: tolerate whitespace and trailing-punctuation drift. | |
| fuzzyThreshold | No | Similarity threshold for fuzzy replace_window matches (0-1, default 0.7). Higher = stricter. 0.9 is recommended for typo-tolerant matching of known-good text. | |
| heading | No | Target heading text for `patch_heading` mode. | |
| headingOp | No | For `patch_heading`. `replace` (default) replaces section; `before`/`after` inserts adjacent to the heading line. | |
| scope | No | For `patch_heading replace`: `section` (default) consumes to next same-or-higher heading; `body` stops at first blank line. | |
| headingIndex | No | For `patch_heading` when the heading appears more than once — 0-indexed top-to-bottom picker. | |
| key | No | For `patch_frontmatter`: the YAML key to set. | |
| value | No | For `patch_frontmatter`: value to set. Use `null` to clear a key. Prefer `valueJson` from clients that stringify params. | |
| valueJson | No | For `patch_frontmatter`: JSON-encoded value (wins over `value`). Use `"null"` to clear, `"true"` for boolean, `"42"` for number. | |
| line | No | For `at_line`: 1-indexed line number (counts from file start including frontmatter). | |
| lineOp | No | For `at_line`: insert before/after the target line, or replace it. Default `replace`. | |
| dryRun | No | If true, return a unified-diff preview without writing. Pass the returned previewId to apply_edit_preview to commit. | |
| from_buffer | No | If true, retry a previously failed replace_window edit using the cached content + search with fuzzy: true, fuzzyThreshold: 0.5. Use when the prior edit failed with NoMatch. Cleared on success. | |
| edits | No | Array of edits to apply atomically to a single file. If any edit fails, no edit is written. Applied in order against the accumulated state (each edit sees the result of previous edits in the batch). Use replace_window / patch_heading for content-anchored edits; at_line references the accumulated state, not the original file. |