Sublime Text editor has built-in syntax highlighting support for too many languages. In case none of the supported highlightings covers your needs you can create your own. The idea of writing custom syntax definitions first came to light (for me) while looking at the log files generated by one of our games (By the way, I am working at PeakGames and we are building awesome mobile games). If the log file contains a lot of information it may be difficult to see the most important parts. Using tools like grep does not really help if you want to see the whole context.
Here is a step by step guide to write your custom syntax highlighting for Sublime Text editor:
Package Control is a package manager for Sublime Text that makes it simple to find, install and keep packages up-to-date.
- Sublime Text is a very popular text editor among coders. It is used for code, markup, prose and more. It is so appreciated because of its smooth interface, rich features, and slick performance. Sublime Text encourages being productive and saving time while transforming writing code in an effortless task.
- Sublime Text editor is a sophisticated text editor which is widely used among developers. It includes wide features such as Syntax Highlight, Auto Indentation, File Type Recognition, Sidebar, Macros, Plug-in and Packages that make it easy for working with code base.
- Sublime Text 3 is the current version of Sublime Text. For bleeding-edge releases, see the dev builds. Version: Build 3211. OS X (10.7 or later is required).
- Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. There is currently no enforced time limit for the evaluation. Changelog 3.2.2 (Build 3211) 1 October 2019. Mac: Added Notarization; Fixed a performance regression when.
PackageDev is a Sublime Text package that helps create and edit syntax definitions, snippets, completions files, build systems and other Sublime Text extension files.
After installing PackageDev, create a new syntax definition file through Tools | Packages | Package Development as seen in the screenshot below.
This is my top 10 list of the Best Sublime Text 3 Plugins Plugins - BracketHighlighter: LiveReload: Si.
Sublime Text Themes
Defining a syntax is simply writing regular expressions to find text in the document. Here is an official documentation about writing syntax definitions for Sublime Text. In this step you need to write regular expressions to match the text in your documents. I have used this online tool to test the regular expressions.
Below is a syntax definition file for our logs. It is good for a starting point because it is simple.
Line Number | Keyword | Description |
---|---|---|
3 | name | Name of your syntax definition. You can select syntax of the document in Sublime Text by View->Syntax as seen in the screenshot below. |
4 | scopeName | This will be used while defining colors in the color theme definition files. |
5 | fileTypes | Sublime text automatically chooses your syntax definition if the file type matches. You can choose the syntax definition explicitly by View->Sytax menu. |
In this step we are going to set colors and text styles (bold, italic vs). Our syntax definition will match the text with the regular expressions and the color theme will change the color and style of the displayed text. Open your favorite color theme. Here is the path to the theme file for Monokai in my computer.
Below is a sample that defines color and text style for text.command pattern (this was defined in the syntax definition on line 9 in the gist above).
That's it. Now the log files are looking much more meaningful when opened in the Sublime Text editor.
Free Sublime Text
- Sublime Text Tutorial
- Sublime Text Useful Resources
Download Sublime Text 4
- Selected Reading
Sublime Text editor is a sophisticated text editor which is widely used among developers. It includes wide features such as Syntax Highlight, Auto Indentation, File Type Recognition, Sidebar, Macros, Plug-in and Packages that make it easy for working with code base. This tutorial gives you a comprehensive coverage of concepts of Sublime Text and makes you comfortable to use it in your software development projects.
The target audience of this tutorial are developers of JavaScript and Python. Web developers who are looking for suitable Text editor like IDE will also benefit from this tutorial. After the completion of this tutorial, you will have an in-depth knowledge of Sublime Text editor.
Before you proceed with this tutorial, we assume that you have a basic understanding of usage of various Text editors like Visual Studio code, PyCharm for Python and Integrated Development Environment (IDE) like NetBeans. You will understand this tutorial better if you have a basic knowledge of text editors.
The current version of Sublime Text editor is 3.0 and is compatible with various operating systems like Windows, Linux and MacOS.