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?

1 Answer 1


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|
    matches an "if" at the start of a line, ignoring white space.

So your pattern should be

  • Thank you so much. Jun 4, 2020 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, 2020 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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