Map files to syntaxes in Tedit on Mac

When you open a document, Tedit detects the document type and automatically applies the appropriate syntax.

Tedit determines which syntax to apply based on the File Mapping rules defined in each syntax definition.

Tedit detects the appropriate syntax in the following order:

  1. Filename:

    Tedit first tries to determine the syntax from the entire filename. Case is generally ignored; however, case-matching filenames are prioritized when multiple syntaxes are found.

  2. File extension:

    If no syntax is found from the filename, Tedit then tries to determine the syntax from the file extension. Case is generally ignored; however, case-matching extensions are prioritized when multiple syntaxes are found.

    For example:

  3. The #! header of the document:

    If no syntax is found based on the file extension or filename, and the first line of the document starts with a #! (shebang) header, Tedit tries to determine the syntax from the interpreter specified in the header. The interpreter can be either the last path component following #! or the argument that follows the path when env is used.

    For example:

  4. XML declaration:

    If no corresponding syntax is found up to this point but the file content starts with an XML declaration, Tedit automatically applies the XML syntax.

    For example:

  5. None:

    If no appropriate syntax can be found, the “None” syntax is applied.

If multiple syntaxes match at the same level, custom syntaxes take precedence over built-in syntaxes. If multiple matches still remain, Tedit uses the syntax that appears first at that priority.

Modify file mapping

To define rules for mapping files to a syntax, select File Mapping from the list on the left side of the syntax editor, then add file extensions, filenames, or interpreters to the lists on the right. See Define a syntax to learn how to open the syntax editor.

Solve file mapping conflicts

There are no conflicts among the built-in syntaxes. However, if you add custom syntaxes or modify built-in syntaxes, file mappings can conflict. You can check for mapping conflicts by choosing Show File Mapping Conflicts from the More menu in the available syntaxes list in Format settings. If the menu item is dimmed, there are no conflicts.

You can leave file mapping conflicts unresolved as long as documents open with the expected syntax. This doesn’t cause any issues.

See also