0

I have some keywords other than TODO used in comments that are common to all languages, things like 'NOTE'.

I want to label these words under Todo syntax class, so that they have the same colour with TODO, but I don't know how to do it globally. Adding the following line to my vimrc doesn't work.

syntax keyword Todo contained NOTE

Does anyone know how to do it globally?

2

You can add this to your vimrc:

autocmd Syntax * syntax keyword Todo contained NOTE

If you want this to work in comments for almost any syntax:

autocmd Syntax * syntax keyword Todo NOTE containedin=.*Comment

I don't remember where it's documented, but containedin= can be a pattern. Most syntaxes use the Comment suffix for comment groups.

  • The first command doesn't work, but the second works! However, I have to remove .*Cmnt part to suppress some error saying the group doesn't exist. Thanks! – A.Stone Feb 26 '17 at 3:20
  • @A.Stone Are you sure the first one doesn't work? I tested it and it works as long as a syntax has a group with contains=Todo. I assumed that was your aim. I guess I didn't notice the error when I tested the second one. I'll remove it from the post. – Tommy A Feb 26 '17 at 3:53

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.