Edit Anything

Professional text and hex editing
with Binary Templates technology.

010 Editor - Text/Hex Editor Homepage

Syntax Highlighting allows applying colors to text in the Text Editor to make certain information easier to see. The easiest way to apply Syntax Highlighting is to click the Syntax section of the Status Bar at the bottom of the application as shown in the figure below. Syntax Highlighters can also be applied using the 'Templates > Syntax' menu. To remove Syntax Highlighting from a file, click on the Syntax section of the Status Bar and select '(none - plain)'. Note the Syntax section is only shown when editing text files and the Status Bar will display 'Plain' if no Syntax Highlighter is active.

Syntax Highlighters can be set to run automatically when files are opened based on their extension or file name. To control which Syntax Highlighters are run on load see the File Mask field of the Template Options dialog, accessed on the menu under 'Templates > View Installed Templates'. To control which Syntax Highlighter is applied when a new file is created see the Manage New File Types button in the Editor Options dialog.

The colors applied for each Syntax Highlighter depend upon the current Theme. Different themes can be selected using the Theme/Color Options dialog. The individual colors for Syntax Highlighters can also be customized by scrolling down to the Syntax Styles section of the Theme/Color Options dialog.

Installing Syntax Highlighters

Syntax Highlighters now use 010 Editor's Binary Templates technology. Each Syntax Highlighter is contained inside of a separate Binary Template bt file. New Syntax Highlighters can be installed from the Template Repository by clicking 'Templates > Template Repository' and locating any Templates in the Syntax category. If a file is opened in 010 Editor and a Syntax Highlighter exists in the Repository which is not already installed, a dialog will be displayed asking to install the Template:

The Syntax Highlighter can be installed by clicking the Install button or ignored by clicking the Ignore button. See Installing Files on Open from the Repository for more information on installing templates on open.

The list of installed Syntax Highlighters is available in the Template Options dialog. All Templates that have the category Syntax are assumed to be Syntax Highlighters and these Templates will appear in the Syntax popup section of the Status Bar. A Binary Template which contains a Syntax Highlighter can be installed in the Template Options dialog by clicking the Add... button and then selecting the Template.

Writing Syntax Highlighters

Starting in version 9 of 010 Editor, Syntax Highlighters are now written as a function inside a Binary Template. This means that some programming is required to create Syntax Highlighters but that they can be very powerful and handle a huge variety of different formats. A number of functions have been provided to make the process of writing Syntax Highlighters easier. New Syntax Highlighters can be created the same way new Binary Templates are created, for example by using the 'Templates > New Template' menu option. Syntax Highlighters should also have their Category set to Syntax in order to be displayed in the Syntax popup menu of the Status Bar when they are installed.

A Binary Template which is used to perform syntax highlighting must implement the special function HighlightLineRealtime. This function is called every time a line of text is about to be displayed in the editor to apply coloring to the line. Note that this function only works on a single line but to handle multi-line syntax highlighting such as multi-line comments, see the special flags parameter of the HighlightLineRealtime function which can be used to pass the status to the next line.

Most Syntax Highlighters make use of Syntax Styles which allow a single style to be used in multiple Syntax Highlighters. For example the Syntax Style "code-comment" is used to specify the color of comments both in C/C++ and PHP. The colors can then be changed using the Theme/Color Options dialog. See the HighlightFindStyle function to connect to styles and the HighlightApplyStyle to apply colors to text.

A set of rule functions is provided for convenience when writing Syntax Highlighters but note that these functions are not required to be used. These functions assume that the current rule (highlighting method) is stored in the flags parameter of the HighlightLineRealtime function. Highlighting rules are provided to color single-line comments, keywords, multi-line comments, strings, tags, etc. See the functions HighlightCheckCommentRule, HighlightCheckKeywordRule, HighlightCheckMultiLineRule, HighlightCheckSingleLineRule, or HighlightCheckTagRule for more information.

In order to save time and memory, Syntax Highlighters allow instance sharing. This means that all open files in the editor can share a single copy of a Binary Template to do syntax highlighting for a particular type. See the HighlightAllowInstanceSharing function for more information.

Syntax Highlighting is only used for text files; however, realtime highlighting can be applied to hex files as well by implementing the HighlightBytesRealtime function. More information is found in the help topic for this function.

Old Syntax Highlighters

In 010 Editor version 8 and previous versions, syntax highlighting was controlled using the 'Tools > Options...' dialog. These type of syntax highlighters are no longer supported. When a newer version of 010 Editor is first run and there exist old custom syntax highlighters, those syntax highlighters will automatically be exported as an XML file to the 'Documents\SweetScape\Old Syntax Highlighters' directory. The old syntax highlighters can also be exported by clicking on the Export Old Syntax Highlighter button in the Highlight Options dialog. If this button is not visible in the dialog then no syntax highlighters could be found to export.

Currently there does not exist any automatic way to convert from the XML file into a Binary Template which can be used for Syntax Highlighting and the conversion must be done by hand. SweetScape Software may be available to help in the conversion of common text formats time permitting and contact SweetScape Software for more information.

This is the manual for 010 Editor, a professional hex editor and text editor. Use 010 Editor to edit the individual bytes of any binary file, hard drive, or process on your machine. 010 Editor contains a whole host of powerful analysis and editing tools, plus Binary Templates technology that allows any binary format to be understood.

Newsletter - Receive special offers, tips, tricks and news. Join now

010 Editor v14.0.1 is here!
What's new?



010 Editor

E-mail: info@sweetscape.com