Only Indent with Spaces in YAML Front Matter (Or Allow YAML Parser to Handle Tab Indentation)

Use case or problem

I don’t know if this is a feature request or bug report, so I’ve put it here initially.

I wanted to organize some data in my YAML frontmatter by keeping it namespaced under parent properties. However, Obsidian is set by default to indent using tabs rather than spaces, and this applies also when editing the YAML frontmatter.

Currently, this results in the frontmatter failing to parse if there are any tab-indented portions. If there are no tab-indented portions then parsing succeeds as expected. If indentation is manually done with spaces then parsing also succeeds, until I meet a tab increment at which point the spaces are converted into a tab and parsing fails again.

Proposed solution

I can think of two possible solutions off the top of my head, though I can’t guarantee this list is exhaustive.

  1. Detect when the user is editing the frontmatter region and always indent by spaces regardless of the tab/space setting.
  2. Configure the YAML parser to accept tab-indentation.

It’s possible that tabs are supposed to be accepted but something else is going horribly wrong along the way, which might make this more of a bug report than a feature request. Programming is fun that way.

Current workaround (optional)

Currently I’m toggling the tab/space setting to indent using spaces. However, this has to be done per-vault which is annoying when I inevitably open a less-touched vault and forget for a moment that I need to do that.

Related feature requests (optional)

I did not see anything else related to this, so I’m probably the one weirdo with overwrought YAML. :stuck_out_tongue:

1 Like

Tab-based indentation is an abomination and should be banned everywhere :stuck_out_tongue:.

You’re not wrong, but that doesn’t resolve my immediate issue :stuck_out_tongue:

Another thought regarding proposed solutions is a visual warning in the editor to tell the user if their frontmatter is invalid, ideally with an indication of where parsing failed, but even a warning that it failed at all is good.

1 Like

The only current workaround is turning this off Settings>Editor>Indent Using Tabs