robcowie / SublimeTODO

**[DEPRECATED]** - See https://github.com/jonathandelgado/SublimeTodoReview - Extract TODO-type comments from open files and project folders
295 stars 54 forks source link

Grouping multiple patterns under a single output header #27

Closed robcowie closed 12 years ago

robcowie commented 12 years ago

Greetings,

I've been using your SublimeTODO plugin for Sublime Text 2 and it's been great. I really appreciate you writing it.

However, I have one question that I haven't been able to figure out on my own (probably owing it my own inexperience with Sublime plugins and Python programming in general.) My question is, is it possible to add multiple patterns to be grouped under one heading in the output file?

For example, can I make it so that both "TODO: blah blah blah" and "dothis: blah blah blah" are both grouped under the "TODO" heading in the plugin's output?

Thanks again, and cheers!

-Matt Torok

robcowie commented 12 years ago

There isn't any direct support for this (it simply didn't occur to me when I wrote it) but, as the patterns are regular expressions we can combine more than one pattern. In your case we could override the TODO pattern with one that matches 'TODO' and 'dothis'.

In your user settings file add a 'todo' section and with a custom TODO pattern. It'll look something like this;

"todo":
{
    "patterns":
    {
        "TODO": "(TODO|dothis)[\\s]*?:+(?P<todo>.*)$"
    }
},

Note the (TODO|dothis) part of the pattern. It matches TODO or dothis.

int3h commented 12 years ago

Thanks, appreciate the answer, and putting it up publicly. I felt odd putting it as an issue, since it was more of a question than a flaw in the software. But this answers the question nicely. Thanks again!

robcowie commented 12 years ago

No problem