8

I came accross this line in a syntax file.. it does not work:

syntax keyword Type Transparent

I guess this has something to see with the fact that transparent is a significant keyword for Vim.

What should I do to escape it, and to get the actual word Transparent colored in my files like all other Type words? What if I stumble one day accross other touchy keywords like keyword, syn, match etc?

11

This is an interesting question and it looks like the documentation does not say anything about escaping those special words. First, special arguments that can appear anywhere depend on which syntax command you use. The documentation mentiones those specials arguments at :h :syn-arguments

The :syntax commands that define syntax items take a number of arguments.
The common ones are explained here.  The arguments may be given in any
order and may be mixed with patterns.

Not all commands accept all arguments.  This table shows which arguments
can not be used for all commands:
                                                        E395
                    contains  oneline   fold  display  extend concealends
:syntax keyword          -       -       -       -       -      -
:syntax match           yes      -      yes     yes     yes     -
:syntax region          yes     yes     yes     yes     yes    yes

These arguments can be used for all three commands:
    conceal
    cchar
    contained
    containedin
    nextgroup
    transparent
    skipwhite
    skipnl
    skipempty

As for the first question, on how to escape those special arguments, I tried using the syntax-keyword special syntax element [] and this does work:

:syntax keyword Type Eins Transparent[] contained[]

The [] is used to denote an optional part of a keyword, so that e.g. Trans[parent] would define the separate keywords Trans, Transp, Transpa, etc and by (ab-)using this, I made the syntax script work as you wanted.

  • And this is a very interesting answer, which made me learn something does solve the problem. Cheers :) – iago-lito Dec 26 '15 at 9:58

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.