Search code examples
vimsyntaxvim-syntax-highlighting

Vim syntax iskeyword command add @ symbol


I would like to highlight the @prefix directive in the RDF Turtle syntax.

I have added a syntax group turtleKeyword which includes the word @prefix using the Vim command sy keyword. Unfortunately, this does not yet work because the default Vim keyword characters do not include @. So I am trying to add the @ symbol to the Vim keyword characters in a Turtle syntax file.

I found the command sy iskeyword defines the keyword characters, but as an option to the command, the @ symbol itself stands for all alphabetic characters.

What option to sy iskeyword includes the @ symbol in the definition of keyword characters?


Solution

  • The isfname and iskeyword options have the same format of options. The format has a predefined meaning for @ which represent any characters that isalpha() returns true. More details at help isf.

    Hence, to include '@' itself, we need to use @-@ for '@'.

    Including @-@ in your iskeyword as below should fix the issue

     set iskeyword+=@-@