The code elements that CotEditor’s syntax coloring uses are as follows:
| Element | Description | Examples |
|---|---|---|
| Keywords | Keywords in source code such as reserved words of programming languages. | for, while, if |
| Commands | Functions or commands in source code. | print, filter, func() |
| Types | Types in source code or headings in structured language. | int, bool, Object |
| Attributes | Attributes in source code. | <html lang="ja">, @classmethod |
| Variables | Variables in source code. | $foo, self |
| Values | Value constants in source code. | Null, True, False |
| Numbers | Numeric constants in source code. | Int i = 0; |
| Strings | String constants in source code. | String s = "Hello World" |
| Characters | Character constants in source code. | Char c = 'a' |
| Comments | Comments in source code. | /* 〜 */, # 〜 |
CotEditor colors the code elements in the following order: 1) keywords, 2) commands, 3) types, 4) attributes, 5) variables, 6) values, 7) numbers, 8) strings, 9) characters, 10) comments. When your document contains an item to be colored that matches multiple categories (for example, keywords and commands), the color of the latter in the order will overwrite the former’s.
Syntax coloring rules are determined by the following settings:
| Field | Description |
|---|---|
| RE | If this option is selected, both Begin-string and End-string will be considered regular expressions (RE stands for Regular Expression). |
| IC | If this option is selected, the case will be ignored during the search (IC stands for Ignore Case). For example, if you set “abc” as Begin-string and check IC, “ABC” or “abc” or “Abc” in your document will be matched. |
| Begin String | A string that denotes the beginning of the search pattern. This is required to search the code elements you want to be colored. |
| End String | A string that denotes the end of the search pattern. This field can be left blank. |
| Description | You can use this field to leave a comment about the term. Description doesn’t affect syntax highlighting. This field can be left blank. |