Gruntfuggly / todo-tree

Use ripgrep to find TODO tags and display the results in a tree view
Other
1.4k stars 135 forks source link

How to get subtags to work #745

Open mattpilott opened 1 year ago

mattpilott commented 1 year ago

Hi i'm having trouble understanding how to get subtags to work. I have add 3 tags P1``P2``P3 and im trying to see these as as top-level tags with the [ ] empty checkbox as the sub tag.

Screenshot 2023-04-10 at 1 27 49 pm

My todos have this format currently P3 [ ] Misc - Replace fixed sizes with clamps

How can achieve this?

mattpilott commented 1 year ago

This is what my tags actually look like at the moment, hopefully i can have it like this:

stephen-hill commented 1 year ago

I too would like to know how to use subtags. Does it need setting up or should it work out of the box?

eportet commented 11 months ago

Assuming you keep the grouping you could edit your settings file by adding: "todo-tree.tree.labelFormat": "${subTag} ${after}"

stephen-hill commented 11 months ago

@eportet Could you expand on your answer because what you've shown appears to be the default value?

stephen-hill commented 11 months ago

Right, I figured it out!

Example TODO comments I will be using in my description of the solution.

// TODO P1 Something
// TODO P2 Something else
// TODO No subtag

First you need to set the subTagRegex setting. This regex is for any text that appears after the first tag. I have chosen to look for a string that starts with an uppercase character followed by more uppercase characters or numbers.

{
  "todo-tree.regex.subTagRegex": "([A-Z]{1}[A-Z0-9]+)"
}

Adding this will group todo's by sub tag in the FLAT view. (I'm not sure why other views do no work). image

You can also add the subtag to your label by adding ${subtag} to labelFormat

{
  "todo-tree.tree.labelFormat": "${tag} ${after} (${subtag})"
}

image

I hope that was helpful.

TranquilOasis commented 8 months ago

{ "todo-tree.regex.subTagRegex": "([A-Z]{1}[A-Z0-9]+)" }

THANK YOU! I cannot tell you how little documentation there is on subtags. This was a lifesaver!