Plugin: Preserve Frontmatter Formatting - stop plugins from reformatting your YAML

Disclaimer

Is this plugin open source? Yes
Is this plugin completely free? Yes
Is this plugin vibe-coded beyond the author’s ability to comprehend how it works? No
Community Directory: preserve-frontmatter-formatting


When any plugin changes a property, even through the official API, Obsidian rewrites the whole frontmatter block. Comments disappear, quotes are dropped, blank lines go, and [a, b] lists get expanded to one item per line. It happens to properties the plugin never touched, and even when the plugin changed nothing.

With this plugin enabled, a property change rewrites only that property, and a change that changes nothing writes nothing.

  • Comments, quotes, blank lines, indentation, inline lists and folded text all stay as you wrote them.
  • It works for every plugin that edits frontmatter through app.fileManager.processFrontMatter(), including some of Obsidian’s own edits, with no cooperation needed from those plugins.
  • No settings. Installing it turns it on; disabling it gives you Obsidian’s behavior back.
  • It never makes a note worse than Obsidian would. When it can’t splice a change in safely (YAML anchors, for example), it falls back to Obsidian’s own rewrite for that one change.

Left: Obsidian. Right: this plugin

A plugin that only reads: rewritten anyway vs kept

The demo vault has buttons that edit a sample note the way other plugins do, so you can compare the result with the plugin on and off: Preserve Frontmatter Formatting: Open demo vault.

3 Likes

Incredibly useful ! Thank you @mnaoumov

1 Like