1

Using the regex \\todo{.\{-}} I am able to match \todo{stuff}

But what I want to match is {stuff} whenever \todo immediately precedes it. Basically I do not want to include \todo in the matched part.

Can somebody please share what is the regex that would achieve this?

2

You want to use the \zs atom :h /\zs:

\zs Matches at any position, and sets the start of the match there: The
    next char is the first char of the whole match. |/zero-width|
    Example:
        /^\s*\zsif
    matches an "if" at the start of a line, ignoring white space.

So your pattern should be

\\todo\zs{.\{-}}
| improve this answer | |
  • Thank you so much. – caffeinemachine Jun 4 at 10:42
  • 1
    Just a note that if this is for syntax highlighting you’ll want to use one of the \@ forms instead of \zs – D. Ben Knoble Jun 4 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.