Search code examples
sublimetext3syntax-highlighting

ST3 - Editing Syntax Files


How does one tinker with Sublime Text 3's syntax definition files?

Previously there used to be, I think, .tmLanguage or .sublime-syntax files that when opened would be in something readable (like XML/YAML).

I've only been able to find anything relating to syntax as .sublime-package files here:

C:\Program Files\Sublime Text 3\Packages

...and they open like this:

SQL.sublime-package

I'm wanting to add some keywords/function names that the SQL syntax highlighting file seems to be missing, but can't a file I can work with.

I'm sure I've done this with a VB syntax file a few years ago and it was a readable file.


Solution

  • Sublime's package files are actually zip files with a changed extension. As a result when you open them up directly, you end up looking at a hex dump of the content instead.

    Although you can use external tools to examine the contents, it's not a good idea to modify the contents of the package directly. When Sublime or package control update a package, they do so by replacing the entire package file. So if you modify the file, your changes may be lost without warning.

    What you can do is create an override instead. In that case you tell Sublime to use your file in place of an existing one.

    An example of that (also relating to the SQL syntax) can be found in this answer.

    You can also view this video for more information on packages and how they work in Sublime.