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)

25 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.
5 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.

1 Like