Is it possible to make ??? (3 question marks) a keyword, and highlight it?

I have tried the following in a syntax file. Other strings on the line are highlighted, but not ???. \?\?\? does not work either.

syntax keyword textTodos TODO ??? XXX LLL
highlight default link textTodos Todo
  • Use a :syn match for the ??? entry instead, that should be the easiest solution.
    – filbranden
    May 14, 2020 at 14:57
  • yeah also easier would be to use the matchadd() and alike functions. May 14, 2020 at 16:31

2 Answers 2


I would recommend to do it with a syntax match like this:

syntax match TQM '???' containedin=ALL
highlight link TQM Todo

If you want to have it always available, you could put the following in your vimrc:

augroup my_syntax_autocmd
    autocmd Syntax * syntax match TQM '???' containedin=ALL |  highlight link TQM Todo
augroup END

syntax keywords are supposed to be - well - keywords. Initially, this meant, it must match the definition of the 'iskeyword' option, which usually does not include the quotation mark. Some years later, the iskeyword option has been de-coupled from the syntax highlighting option and now one can use the :syn iskeyword command to specify the iskeyword option only for syntax highlighting (which falls back to the iskeyword) option, if it is not specified.

To make this possible, you can add the ? to the syntax definition of a keyword by using :syn iskeyword=<c-r>=&iskeyword<cr>,?

This uses the expression-register = to get the current value of the iskeyword option and adds the ? to it.

Note however, this can have unwanted consequences to your syntax highlighting, depending on the patterns used in the syntax definitions.

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.