In a custom java syntax file (${HOME}/.vim/syntax/java.vim) I wrote

syntax match CommonVar /ret/
highlight CommonVar cterm=bold

with the intention display the word ret in bold. I tested it with this example from a .java file

long ret = 42;
long somearray[] = {ret};
int otherarray[ret];

and discovered that word ret is bold only in the first two lines, but not in the last two.

Surprisingly when I tested likewise with a custom C syntax file and the lines in a .c file ret was bold in all four lines!

What causes this behaviour and how can I modify my syntax file such that ret will always be shown in bold?

  • If I had to guess, I would say it had something to do with contains. You could probably use syntax keyword though – D. Ben Knoble Aug 1 at 23:45

Your Answer

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

Browse other questions tagged or ask your own question.