jokoon
jokoon

Reputation: 6653

How can I add syntax highlighting for operators in sublime text?

I want to highlight +-*=/[](){}%^&$ characters with a color of my choice.

I tried to do it with some answers I found on stackoverflow, but without success Syntax highlighting for >= and <= operators in Sublime Text When I tried it, it changed the color of all normal text.

I noticed it's possible to customize syntax highlighting, but the article on it is pretty long. http://sublimetext.info/docs/en/extensibility/syntaxdefs.html

Any clue how to do it ? I already have an existing theme I made, all I want is to highlight those characters.

Upvotes: 0

Views: 498

Answers (1)

jokoon
jokoon

Reputation: 6653

I managed to do it, apparently some characters like [] and ; aren't "scoped", but for the other, I did it. Here is what I added in my .tmtheme

    <dict>
        <key>name</key>
        <string>char ops</string>
        <key>scope</key>
        <string>keyword.operator.arithmetic, punctuation.definition.generic.end, punctuation.definition.parameters, keyword.operator.assignment, punctuation.separator, keyword.operator.comparison, punctuation.definition.scope,punctuation.definition.block, punctuation.definition.dictionary, punctuation.definition.list,punctuation.definition.arguments </string>
        <key>settings</key>
        <dict>
            <key>fontStyle</key>
            <string></string>
            <key>foreground</key>
            <string>#ffff50</string>
        </dict>
    </dict>

Upvotes: 1

Related Questions