Syntax highlighting

Syntax highlighting is set up in the file kon.syn. Defining syntax highlighting for a filetype is mainly done by specifying for which file extensions the scheme should be activated, listing groups of keywords and the color each group should have, and perhaps certain other primitives such as how comments are defined, and which character are used to delimit words.

Kon can also define syntax highlighting using regular expressions.

In the definition for each filetype, you can also specify how code sections should be identified using regular expressions. The identified code sections will be shown in a drop-down list for fast navigation.

The layout of kon.syn is as follows:

// Color definitions, set color and font attributes statements may appear 
// before any syntax definitions

define color Blue = 0,0,255
define color Cyan = 0,128,128
define color LightGray = 128,128,128

// ------------------
// K syntax highlight

name = "K"  // The name of this syntax highlighting scheme

extensions = .k  // The extension(s) for which this scheme should be used

sections = "^([:m]+)\\(", 1  // Regular expressions defining code sections in the file

set caseinsensitive = no  // yes if all keywords are case insensitive

literal = \  // Escape character

set foreground = Blue  // All keywords defined after this should have it's 
                       // foreground set to blue (RGB 0,0,255 above)

delimitors = ",;:\"'[](){}-+="  // Delimitors separating words (apart from 
                                // white-spaces)

// Blue keywords
keyword = break, case, continue, default, do, else, for, if, 
          return, switch, while

set foreground = Cyan  // All keywords defined after this should have it's 
                       // foreground set to cyan (RGB 0,128,128 above)

eolword = #include     // A word where the color settings will extend to the
                       // end of the line

set foreground = LightGray  // All keywords defined after this should have it's 
                            // foreground set to LightGray 
                            // (RGB 128,128,128 above)

set fontattribute = italic  // All keywords defined after this should have 
                            // an italic font


eolcomment = "//"           // A comment to the end of line

set fontattribute = normal  // Set the font back to normal

pair = "'":"'", '"':'"'     // Strings declaration

grep = (0x[0-9abcdef]+)     // A regular expression which in this case defines
                            // what is a hexadecimal value. Note that parts
                            // which should be highlighted must be defined
                            // as groups: (Enclosing in '('..')').

// --------------
// .syn highlight

// Repeat as above for a different scheme
.
.
.

The following commands can be used in kon.syn: