I'll leave ? at the beginning of a commented line to mark a todo item.
-- ? TODO ...
This line will be marked as comment.
How to highlight the ? and the remaining text by Todo color while keep the -- as comment color?
You'll need to know what syntax item your filetype uses for comments.
The only languages I know that use --
as a comment marker are Ada and MySQL. For these, use the following lines, respectively:
syntax match Todo /--\s*\zs?.*/ containedin=adaComment
syntax match Todo /--\s*\zs?.*/ containedin=mysqlComment
We're matching the entire comment (because we don't want question marks halfway through a comment to be marked as TODO items), but using \zs
to tell Vim to only start highlighting at the ?
.
Breaking down the regular expression:
--\s*
: Match two dashes followed by any amount of whitespace,\zs
: "Start" the match,?
: Match a question mark,.*
: Match anything else that follows on that line.