Home

Awesome

Synesthesia

A Sublime Text 3 plugin for highlighting text with pretty colours.

Installation

Getting Started

Functionality

This plugin provides a quick and lightweight way to highlight text with different colours.

It takes a highlighting scheme, which is a description of words to highlight and how they should look, and generates all the necessary configuration files for Sublime to render them that way.

This is essentially an abstraction for creating a language definition, but much easier to use: you don't have to deal with all that complexity if all you need is to bring attention to a few terms in your text, colour a log file, etc.

The rest of this readme thoroughly documents all the options you can use. You may also wish to browse the examples in Packages/synesthesia/include.

What should you use this plugin for?

Colours

Keyword colours are specified as RGB in hexadecimal form (#rrggbb). We can also use colour names, like blue or red; a list of these can be found here.

Two additional colour types are available: random and auto. random will give a random colour on every compile, while the colour that auto generates is fixed. Both will only generate nice bright colours.

{
	'keywords': {
		'roses': '#ff0000',
		'violets': 'blue',
		'lazy?': 'random',
		'no problem!': 'auto'
	}
}

Formatting and Options

Options can be specified instead of a colour name or value:

{
	'keywords': {
		'something': {
			'colour': 'plum',
			'background': 'blue',
			'bold': true,
			'italics': true,
			'whole-word': true,
			'case-insensitive': true
		}
	}
}

Keywords

Keywords are specified using Oniguruma regular expressions, which is what Sublime uses under the hood. Don't worry if you aren't familiar with these: alphanumeric strings are valid regexes, so you don't need to be an expert to use this plugin.

Mixins

We may find ourselves always wanting to highlight the same things. For example, we want ERROR to appear red, in bold font, whether in upper case or lower. It can be tiresome to define it again and again.

That's where this option comes in. Highlighting schemes can be mixed into others with include, so we can easily separate and combine them:

{
	'include': ['LightMarkdown'],
	'keywords': {
		...
	}
}

This will cause the keywords and colours in LightMarkdown.json to be copied into the current scheme on compile.

Here's how Synesthesia will search for schemes to mix in:

File Extensions

File extensions for highlighting schemes go under extensions. This is so they apply automatically when files of the type are opened.

{
	'extensions': ['txt', 'md'],
	'keywords': {...}
}

By default, txt and md will be used.

Autocompletion

{
	'autocompletion': true,
	'keywords': {...}
}

If set to true, Sublime's autocompletion will be enabled in the generated language definition.

Other Settings

{
	'keywords': {
		...
	},
	'settings': {
		'font_face': 'Open Sans'
	}
}

Other settings for the generated language definition go here.

Removing Highlighting Schemes

To remove highlighting schemes, select Remove Highlighting Scheme from the Command Palette.

Don't delete the files manually. Sublime Text will complain about that, and you might have to reinstall the package to fix the resulting errors.

Inner Workings

Compiling a highlighting scheme generates three files:

The first two work in tandem, specifying a mini-language consisting of the user's keywords, along with a colour theme designed specifically for that mini-language. The settings file glues them together, causing Sublime Text to associate the theme with the mini-language. All this is done via Sublime Text's built-in mechanisms for syntax highlighting, so it's robust and stable.

Other plugins for highlighting arbitrary words do so either via named regions or by mutating the current colour theme.

The method used in this plugin, while static, is great for live editing and is much simpler to manage. Interactions with other language definitions are also made explicit. I see it as the middle ground between these approaches.

License

MIT