Skip to content

Snippets Highlight file format

prudnikov edited this page Feb 15, 2011 · 3 revisions

Highlight file is a valid XML document in a UTF-8 encoding with an extension .snippetshl and having the following format:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key1>
	<value1>
	<key2>
	<value2>
	…
</dict>
</plist>

Snippets has support for the following keys:

  • Label — the value should be unique for each highlight. In other words, this is identifier of the highlight. For example:
<key>Label</key>
<string>objective-c</string>
  • Name — the value should represent a display name for application UI.
<key>Name</key> 
<string>Objective-C</string>
  • Extension — the value must be a file extension (without leading dot) for exporting the snippet of the given highlight. For example, "cpp".
<key>Extension</key>
<string>m</string>
  • Case-insensitive — the value should indicate if highlight is case-insensitive or not. Define <true/> for highlights with case-insensitive identifiers and <false/> for highlights with case-sensitive identifiers. This key is optional and equal to <false/> by default. For example:
<key>Case-insensitive</key>
<true/>
  • Line — the value is a dictionary of attributes for such one-line entities as single-line comments and directives.

  • Multiline — the value is a dictionary of attribues for such multi-line entities as multi-line comments and strings.

  • Identifier — the value is a dictionary of special words that will be highlighted in the Editor.

Dictionaries for keys Line, Multiline and Identifier should have the following format:

<dict>
	<key1>
	<value1>
	<key2>
	<value2>
	…
</dict>

You can define the following keys in the Line dictionary:

  • Directives — the value is an array of dictionaries in format
<dict>
	<key>Start String</key>
	<string>START_STRING</string>
</dict>

where START_STRING is a start of directive line within a source code. For example:

<key>Directives</key>
<dict>
	<key>Start String</key>
	<string>#!</string>
</dict>
  • Comments — the value is an array of dictionaries in format
<dict>
	<key>Start String</key>
	<string>START_STRING</string>
</dict>

where START_STRING is a start of comment line within a source code. For example:

<key>Comments</key>
<dict>
	<key>Start String</key>
	<string>//</string>
</dict>

You can define the following attributes in the Multiline dictionary:

  • Strings — the value is an array of dictionaries in format
<dict>
	<key>Start String</key>
	<string>START_STRING</string>
	<key>End String</key>
	<string>END_STRING</string>
</dict>

where START_STRING is a start of a string within a source code, END_STRING is an end of a string in the source code. For example:

<key>Strings</key>
<array>
	<dict>
		<key>Start String</key>
		<string>"</string>
		<key>End String</key>
		<string>"</string>
	</dict>
</array>
  • Comments — the value is an array of dictionaries in format
<dict>
	<key>Start String</key>
	<string>START_STRING</string>
	<key>End String</key>
	<string>END_STRING</string>
</dict>

where START_STRING is a start of a multi-line comment within a source code, END_STRING is an end of a multi-line comment in the source code. For example:

<key>Comments</key>
<array>
	<dict>
		<key>Start String</key>
		<string>/*</string>
		<key>End String</key>
		<string>*/</string>
	</dict>
</array>

You can define the following attributes in the Identifier dictionary:

  • Keywords — the value is an array of strings in format <string>KEYWORD</string> where KEYWORD is a keyword for the given highlight. For example:
<key>Keywords</key>
<array>
	<string>for</string>
	<string>case</string>
	<string>switch</string>
</array>
  • Custom Identifiers — the value is an array of strings in format <string>IDENTIFIER</string> where IDENTIFIER is an identifier that will be highlighted slightly different than keywords. For example:
<key>Custom Identifiers</key>
<array>
	<string>NULL</string>
	<string>TRUE</string>
	<string>FALSE</string>
</array>