Parent page: TextEdit Commands
The following pre-packaged resource, derived from this base command, is available:
Edit Language Syntax
Applied Parameters: None
Summary
This command is used to access the Syntax Editor dialog, from where the syntax scheme for the language associated to the current document can be defined/edited. Syntax highlighting is a method used to make text documents more readable, where different elements in the document are highlighted based on their syntax. The way this is done is to assign different words, symbols and identifiers a unique color. This set of color assignments is called that language's syntax.
Access
This command is accessed from the Text Editor (or any coding-aware variant of the Text Editor), by clicking the button on the Utilities toolbar.
Use
After launching the command, the Syntax Editor dialog will appear. The dialog is divided into five tabs, each representing a different area of the language's syntax:
- Options - used to define various general syntax options.
- Comments - used to define comments. Comments are elements in the text file that you wish to define as code comments. These can be defined as single-line, full-line or multi-line comments. Comments are defined by their delimiters, that is, the characters that indicate that a block of text is a comment. Single line and full-line comments only require a left delimiter (the other end is defined by an EOL character). Single line comments can commence anywhere on a line, full line comments require the comment delimiter to be the first character on the line. Multi-line comments require a left delimiter and a right delimiter to define where they start and end.
- Strings - used to define strings. Strings are elements in the text file that you wish to define as strings in the code, such as strings that appear as a message in a dialog that your program displays. Both single-line and multi-line strings are supported and both types require the left and right delimiters to define their start and end point.
- Numbers - used to define numbers. Like comments and strings, numbers are another class of information in the document that you may wish to make stand out. Simple numbers are defined as being strings of numeric digits, which may or may not contain a decimal point, for example 45, 45.6 but not 45.6.6. Simple numbers can also include an E character, denoting scientific notation, such as 53E3, or 24e6. Special numbers are defined as having a prefix and/or a suffix and contain numerical digits, or the letters A-F. These could be used to tell a compiler that the number is hexadecimal or octal, for example. Examples of these numbers are 0xAF034AD, 88j, j8A8y, but not 0xA.4. Each number type is specified by a suffix, a prefix or a prefix and suffix combination. The basic behavior of prefixes and suffixes is that whenever a valid prefix or suffix is detected in combination with a number, then the number and the prefix (or suffix) is highlighted, according to the number style. This basic behavior can be modified through additional available options.
- Keywords - used to define keywords. Keywords are a set of pre-defined words that you would like to stand out in your document. Typically these are words reserved by the programming language to identify a specific function, procedure, object type, and so on. Keywords are defined as part of one or more keyword sets, each with its own style (color and font parameters), further enhancing the readability of your document.
Tips
- Enable/disable syntax highlighting for each of the syntax elements in their respective tabs. If the highlight option for a syntax element is disabled, then any such syntax that exists in the document will become unhighlighted and will revert back to the style for normal text.
- If the same keyword appears in more than one keyword set, then the highlighting style of the set that appears first in the list will be applied.
- Keywords can contain alpha and numeric characters and also the underscore character. The keyword cannot begin with a numeric character.