Autocomplete Tags in YAML front matter

Use case or problem

tags in YAML front matter is time consuming because the autocomplete feature doesn’t work for tag names, unless the tag is input with a hash symbol in front of it.

Proposed solution

implement Autocomplete in the YAML front matter

Current workaround (optional)

No work around as such.

YAML only recognizes strings, and that means I have to type the tag with the hah symbol so as to make use of the autocomplete, and then engulf the tag in single braces. This takes quite some time!

Related feature requests (optional)

33 Likes

I’d love this feature as well, but I do have a workaround.

  1. start typing #<tag goes here..> in the YAML frontmatter. You’ll find autocomplete options.
  2. Select what you want
  3. Remember to delete the # at the beginning, otherwise it’ll be considered a comment.
9 Likes

I am also facing this issue and it would be great that tags autocomplete in YAML frontmatter. Ideally, both "#…" and plain text should work for autocomplete, in both list and bracket formats (having already one of all working would be nice).

3 Likes

Thank you! I was searching the forum looking for exactly this. I just started actively using YAML frontmatter in the last couple of days. Every new note has it with tags, and if I pull up an older note that doesn’t, I add. Really working for me… except for the autocomplete issue. I was finding I was also needing to use the Tag Wrangler plug-in regularly to rename/combine tags.

I’ll try the workaround of typing # and then removing, but not ideal.

2 Likes

I solved it with the AHK script (Autohotkey app for PC must installed). I will write in the line: tags: [ #newtag ] when I will suggest the used tags. I stay in line and run the script. He first checks to see if I’m in the tags: line and then removes all # characters in that line in bulk.

Probably a better script to write, but I’m a beginner.

#IfWinActive, ahk_exe Obsidian.exe ;you must by in the obsidian window
{
 ; CTR+SHIFT+A shortcut for run the script. Character "A" you can change it for your own shortcut
^+a::Gosub, obsidianHashTagReplace
return
}

obsidianHashTagReplace:
send, {home}
send, +{End}
send, ^c
If InStr(Clipboard, "tags: [")
{
} Else {
	MsgBox, You are probably not in the YAML Tag line.
	Exit
}
Clipboard := StrReplace(Clipboard,"#","")
send, ^v
return

I am assuming that this patch isn’t yet a plugin, or accessible to the majority of Obsidian users,

so the feature request is still alive?

Agreed. I have to remove the extra # symbol every time

Want this feature!

If this is still an issue for others, it’s possible to retain the # by quoting each tag after autocompleting or quoting them all together. This works for me in v0.12.15 without issue:

This one seems to be the most practical for me:

tags: "#tag1 #tag2 #tag3"

These also work though:

tags: "#tag1" "#tag2" "#tag3"

…or…

tags:
  - "#tag1"
  - "#tag2"
  - "#tag3"
1 Like

The Obsidian linter plugin now has has a rule to reformat tags in the YAML frontmatter, which also solves the issue conveniently.

5 Likes

Use case or problem

This is about tags in the metadata section.

---
# metadata section
tags: some_tag, #some_other_tag
---

# normal document

If I write some_tag I do not get any suggestions from existing tags. I might mistype it and not who up in a query for the real spelling.

If I type it with # like #some_other_tag I do get suggestions. But after saving/closing the document. It does not show up in searches for the tag. It does not count as tagged with some_other_tag.
I suspect it is treated as a comment but I don’t think it should.

Proposed solution

Two approaches:

  1. Don’t ignore tags with#. The search (and links, etc.) for tags:#some_other_tag should should the document with the line tags: #some_other_tag
  2. When typing something in the metadata section on the line beginning with tags: , suggest tags like when typing #

Current workaround (optional)

Use # for suggestions and the delete the #. :frowning_face:

Another workaround in the meantime: Frontmatter Tag Suggest Plugin, not in the store yet but available to install manually or through BRAT

1 Like

Hi,
I just checked on Mobile. Frontmatter Tags work as expected in Search. I enter my Frontmatter Tags like so in Edit Mode:

tags: [Fotografie Fujifilm Filmsimulation Astia]

and they show in the Metadata section in Preview Mode like so:

Tags #Fotografie #Fujifilm #Filmsimulation #Astia