P language plugin for Sublime Text 3. Includes basic syntax highlighting, comments format and some snippets.
Use the Command Palette to Add Repository
and add this GitHub repository.
Then use the Command Palette to Install Package
and search for and install Sublime-P
.
The syntax highlighting assumes the following conventions, but you don't have to follow them.
- Type names end with
Type
. E.g.StartMessageType
. - Fields end with
V
. E.g.TimerV
. - Events start with
e
. E.g.eStop
,eStart
. - Machine names end with
Machine
. E.g.ElevatorMachine
. - State names have no conventions and so have no color.
These conventions are followed by the snippets, so you don't have to remember them.
Snippets include: event
, implementation
, machine
, module
, test
, type
, var
(for fields), whileindex
.
To use a snippet, start typing one of these words and press tab. Then continue typing to replace the placeholder names and press tab further times to jump to the next placeholder or cursor position.
E.g. Start typing while
. The whileindex
completion pops up. Press tab to get:
index = 0;
while(index < sizeof(Array))
{
index = index + 1;
}
Typing will replace all instances of index
. Pressing tab jumps to Array
which is the next placeholder. Pressing tab again places the cursor after the first curly brace.
The p.tmLanguage
file defines the syntax highlighting. It is a generated file, but is committed for convenience.
To make changes, do the following:
- Install Package Control in Sublime Text 3 and then use the Command Palette
Ctrl+Shift+P
toInstall Package
and search for and installPackageDev
. - Open
p.YAML-tmLanguage
. - Make your changes.
- Use the Command Palette to execute
Build With: Convert to ... - Property List
.