Changelog (refer to linked posts for newest files)
I use (the fantastic)
Sublime Text as my text editor, and got a little tired of staring at white text in my .list file. So, I cobbled together a little .sublime-syntax file that provides some rudimentary syntax highlighting for TM .list files (mostly by
mangling the scope naming conventions, but it's a nice shortcut to adjusting a color scheme file). I do not know whether it works with
Sublime Merge. I hope someone finds it useful
Here's a (very scaled down) picture:
Features:
- Comments (lines beginning with '#' but not '#--' or '#{xx}') appear as normally in syntax highlighted languages, gray. Two 'special' comment lines which I personally use are defined below.
- Entries are matched in their entirety -- a partially completed entry does not get syntax highlighting and appears plain white while a complete entry is highlighted. A complete entry is defined (per my reading) by 4 sets of non-whitespace characters each separated by a single whitespace character. Region is colored like a function, Highway is colored like a keyword, and Waypoints are colored like strings.
- '#{xx}' (where xx is anything except whitespace, including nothing -- i.e. '#{}') is highlighted like a Markdown heading. With the Monokai color scheme, this means the '#{xx}' prefix is bold orange while the rest of the line is bold white. I use this as a searchable section heading.
- '#--' is highlighted like a language constant (darkish blue in Monokai). I use this as a searchable subsection heading.
You don't have to use the 'special' comments or can delete them from the YAML file below.
To get syntax highlighting, download the attached files and place them in %APPDATA%\Sublime Text 3\Packages\User\ (or an equivalent for OS X or Linux). The .tmPreferences file is required if you want to toggle comments using Ctrl + /. I have also placed the content of the files in code blocks so they are accessible if someone isn't logged in to the forums.
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: List (TravelMapping)
file_extensions:
- list
scope: text.list
comment: |-
this syntax document makes TM .list files prettier
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
prototype:
- include: comments
main:
# \S matches non-whitespace, \s matches whitespace.
- match: '^(\S+)\s(\S+)\s(\S+)\s(\S+)'
captures:
1: support.function # Region. could create entity.name.region
2: keyword # Highway. could create entity.name.highway
3: string # Waypoint 1. could create entity.name.waypoint.one
4: string # Waypoint 2. could create entity.name.waypoint.two
comments:
# Comments begin with a '#' and finish at the end of the line.
# Heading 1
- match: '#{\S*}'
scope: punctuation.definition.heading
push:
- meta_scope: markup.heading
- match: \n
pop: true
# Heading 2
- match: '#--'
scope: punctuation.definition.heading
push:
- meta_scope: constant.language
- match: \n
pop: true
# Normal comments
- match: '#'
scope: punctuation.definition.comment
push:
- meta_scope: comment.line.number-sign
- match: \n
pop: true
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>text.list</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string># </string>
</dict>
</array>
</dict>
</dict>
</plist>