CotEditor continuously analyzes the contents of your document and smartly supports text editing by visualizing structure with color, extracting an outline, and inserting comment delimiters according to each language’s grammar. These behaviors are organized as a “syntax” for each document type.
A syntax defines the behaviors of the following features:
Syntax highlighting colors elements in a document according to predefined rules.
For example, in program source code, commands and variables can be color-coded according to their grammatical roles, making the structure of the code easier to understand. Syntax highlighting is also useful for structured formats like Markdown, or for drawing attention to characters or words that should not be used.
A syntax defines the semantic rules for highlighting, whereas a theme specifies the colors for highlighting.
The Outline feature extracts specific parts of a document based on the syntax definition and generates an outline list.
For instractions how to use the Outline feature, see Inspect the outline of a document.
The Comment Out command intelligently inserts or removes the appropriate comment delimiters used by programming languages in the selected text. Comment-related commands are grouped in the Text > Comment menu.
You can include syntax-specific reserved words to the completion list.
For details about the completion feature, see Complete a word.
A mode is a feature that lets you change the editor’s font and behavior in a unified way according to the type of document. The editor can can switch its mode automatically based on the “kind” of the syntax applied to the document, or you can create individual mode settings for a syntax.
For details, see Switch editor modes.
CotEditor includes a wide range of built-in syntaxes for many major languages.
CotEditor automatically applies a syntax based on the document type. You can also set it manually from the Syntax menu in the toolbar or the Format menu.
Each syntax defines its own file-mapping rules. To learn how CotEditor determines which syntax to apply, see Map files to syntaxes.
CotEditor includes built-in syntax definitions for many major programming languages. You can also customize the built-in definitions or add your own. For details on editing syntaxes, see Define a syntax