Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

YAML to tmTheme

Color schemes for the TextMate and SublimeText editors (tmTheme files) are stored as plist XML, which is not the most human friendly format to edit and maintain.

This project is an example of generating tmTheme files from YAML sources using a Python script. This has a number of advantages:

  • easy for humans to read and modify
  • little structural overhead
  • schemes can be modularized
  • allows simple templating

Example schemes:

Related work:


The scripts are written for Python 3, and use PyYAML. takes one or more YAML files and generates a tmTheme file. An optional dictionary can be provided.

usage: [-h] [-d DICT] infile [infile ...] outfile

Convert YAML to tmTheme.

positional arguments:
  infile                YAML scheme file
  outfile               tmTheme scheme file

optional arguments:
  -h, --help            show this help message and exit
  -d DICT, --dict DICT  YAML dictionary file

All input files are concatenated before they are processed, so it is important to divide files in a way that maintains the structure of the content. For tmTheme files this usually means keeping all top level keys in the first file, ordered so settings is last. This way all further files go into settings.

The dictionary is a YAML file mapping identifiers to their replacement. In the strings of the input file (both key and value), $identifier will be replaced with the value of identifier in the dictionary. $$ is an escape to insert a literal $. converts a tmTheme file to YAML. The generated file is a simple dump, but can serve as a starting point.


Given a scheme file

name: $name
uuid: $uuid

# Editor settings
- settings:
    background: $blue
    foreground: $white

# Root groups
- name: Comment
  scope: comment
    foreground: $gray

and a dictionary

name: Simple Blue
uuid: e42124f9-7cf8-4477-ad7b-31a7f1050504
blue: '#0000FF'
white: '#FFFFFF'
gray: '#808080' -d dict.yaml scheme.yaml scheme.tmTheme will generate

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
	<string>Simple Blue</string>


This projected is licensed under the terms of the MIT license.