# Define a syntax in CotEditor on Mac

CotEditor's syntax defines the behavior of several functions related to document editing, such as syntax highlighting, extraction rules of Outline, grouped by document type (syntax) so that they can easily be switched depending on the document.

CotEditor automtatically applies one of syntaxes according to the document type. You also can manually set it by selecting a new one from the Syntax menu in the toolbar or the Format menu. A syntax itself defines the rules to which documents the syntax is applied. See Map files to syntaxes to know how CotEditor selects the syntax for a document.

In CotEditor, a syntax defines the behaviors of the following features:

- Kind of syntax
- Syntax highlighting
- Extraction rules of Outline
- Comment delimiters
- Word completion
- File mapping

## Manage syntaxes

CotEditor bundles syntax definitions for major languages. You can also modify them or add new syntaxes. To manage available syntaxes, choose CotEditor > Settings, then click Format. All syntaxes available are listed in the “Available syntaxes” list.

To add a new syntax, click the Add (plus icon) button below the list. To use an existing syntax as a template for creating your own, choose the Duplicate command in the Action pop-up menu instead.

## Edit syntax definition

A syntax definition can be edited through the syntax editor. To open the editor:

1. Select the syntax you want to customize from the Available syntaxes list.
2. Double-click the syntax name, or click the Edit button.

In the syntax editor, choose settings for the syntax:

- Name: Change the syntax name.
- Kind: Define whether the syntax is for coding or for general purpose. This option affects the editor’s font and behavior set in Mode settings.
- highlighting elements: Define the rules of the syntax highlighting.
- Comments: Define the comment delimiters and syntax highlighting for comments.
- Outline: Define the extraction and formatting rules of outine items for the Outline feature.
- Completion: Define the text completion candidates.
- File Mapping: Define the file attributes to map the syntax.
- Information: Change the metadata of the syntax definition.
- Validation: Verify that no grammatical or formatting errors exist in the definition.

## See also

- Change Format settings