Custom syntax highlighting in Sublime Text 2

I want to use Sublime Text as a log viewer. This is why I need to create a tmlanguage file to highlight the word "ERROR" (and some others). Is there a tmlanguage xml specification, or can you give me a basic example of a syntax highlighting file for sublime text 2?

I did not find the answer in a similar question: Syntax highlighting using Sublime Text 2

+43
sublimetext2 syntax-highlighting
Mar 05 '13 at 10:13
source share
2 answers

Sublime Text uses the same syntax highlighting as TextMate. Grammar can be found here . I would recommend working in JSON and then converting to XML, as it is easier (at least for me) to read. The PackageDev plugin will give you the source snippet for defining the new syntax. It also contains syntax highlighting for configurations, as well as a Plist to JSON converter. The following is a snippet from the protobuf syntax definition file that highlights certain words. As for the colors of the highlights, you'll have to browse your color scheme file. In the example below, you will look for the "constant.language" area for the color used. You probably don't need to edit the color scheme unless you want something else other than what's already built into your scheme.

{ "name": "Protocol Buffers", "scopeName": "source.proto", "fileTypes": ["proto"], "patterns": [{ "match": "\\b(bool|bytes|double|fixed32|fixed64|float|int32|int64|sfixed32|sfixed64|sint32|sint64|string|uint32|uint64)\\b", "name": "constant.language.proto" }], "uuid": "8c8714d5-43ef-43d2-abd9-c9088901ddd5" } 
+38
Mar 06 '13 at 0:48
source share

You can play with this application. Many languages โ€‹โ€‹have good definitions from which you can work.

http://tmtheme-editor.herokuapp.com/#/Cobalt

+6
Aug 11 '13 at 6:26
source share



All Articles