Sublime Forum

Build New Syntax Highlight

#1

Good evening.
I’m going crazy with the construction of a syntax.
How can I highlight with a yellow background the following string that always begins with a dot?

.string-that-always-begin-with-dot

Thank you.

0 Likes

#2

Have you read http://www.sublimetext.com/docs/3/syntax.html? It goes through various features, although it is hard for me to evaluate from the perspective of someone new to the subject.

In short, you write regular expressions to match text into tokens and assign scopes to them. There is functionality to highlight text differently based on the context. For instance, you may only want to highlight .string-that when not inside of a string. You start in the main context and can push into other contexts as you need to, and then pop back out when done.

However, your syntax will never choose what color a token is. Instead it assigns scopes to tokens, and then your color scheme sets the color for the scope. http://www.sublimetext.com/docs/3/scope_naming.html talks about common scope names as used in syntax definitions and color schemes.

2 Likes

#3

Thank you for reply.
It is too hard for me to understand the wiki documents.
I do not speak English and it is not easy even with translators.
Is possible to have a sample file on other syntax?
Thanks again.

0 Likes

#4

You may see my syntax file for Amxx Pawn. There are some comments from the doc. You may see if you understand them within the code.

  1. https://github.com/evandrocoan/SublimeAmxxPawn/blob/master/AmxxPawn.sublime-syntax

Also see the default Sublime Text syntaxes files and this thread below, there are some useful links there for regex learning:

  1. https://github.com/sublimehq/Packages Default Sublime Text Syntaxes
  2. Not able to show errors messages inline for my custom build system
0 Likes