How to change a line of tags to a list of tags in yaml?

What I’m trying to do

I have already had a bunch of notes with tags in yaml in a line, such as

---
tags: tag1 tag2 tag3 ...
---

what I would like to do, whether can change these tags in to a list, like this:

---
tags:
  - tag1
  - tag2
  - tag3
  - ...
---

thanks for helps.

Things I have tried

I had try the linter plugin, with several possible settings I guessed, none of them works.

One easy way would be to interact with the Properties in document in any way. Obsidian will reformat them.

CleanShot 2024-03-31 at 12.56.49


You could also try app.fileManager.processFrontmatter() with Templater, detailed here:

Backup before any vault-wide changes!

Normally interacting with the properties would trigger a reformat, but if you really have spaces to separate your Tags you’ll need to do some search and replace, or template action on them to change into a proper list of tags.

If on one line they need to be comma separated for Obsidian to reformat them into a proper list, if I’m not mistaken.

In this case, comma separated or not, the reformatting is the same.

CleanShot 2024-03-31 at 19.30.04

Hmmm, I know there is some special treatment of tags, but I was sure this wasn’t handled. I stand corrected, @ariehen, thanks for correcting it.

I didn’t try now but I’m guessing it should work, although I am again not sure how Linter would handle the comma-less situation…
The settings I have and would expect to work:

If you have hundreds of files, all of them can be linted in bulk.

Thanks.

with all your suggestions and helps, I find the settings in linter plugin, and now it’s no longer a problem.

Thanks you all.