This small step-by-step guide assumes you already have Package Control installed in ST3.
If not please see Package Control Installation to install Package Control and then Usage: Install Package to learn how to install packages.
- First install Craft-Twig from Package Control.
- Then install Sublime Project Specific Syntax from Package Control.
- Open any file and change it's syntax to HTML (Twig) by clicking on the current syntax (bottom right.)
- Next Right-Click anywhere in the writing area > Project Specific Syntax > Copy syntax setting to clipboard.
- If you haven't already, open your project in ST and Project > Save Project As. Give your project a name and save the file. Probably above root along with the craft folder.
- Then Project > Edit Project which opens the {yourprojectname}.sublime-project file (the file you just saved in the previous step.)
- Add in syntax_override from the Sublime Project Specific Syntax instructions and paste in your syntax which you copied from step 4 (see code examples below.)
- Save the project file.
- Done!
Now with every .html file you create the syntax should be set to HTML (Twig)!
syntax_override
should look something like the following:
"syntax_override":
{
"\\.html$": ["Craft-Twig", "Syntaxes", "HTML (Twig)"]
}
My *.sublime-project
file now looks like this (yours may differ depending on your setup):
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"syntax_override":
{
"\\.html$": ["Craft-Twig", "Syntaxes", "HTML (Twig)"]
}
}
- As far as I know you have to manually set existing HTML files to HTML (Twig) syntax yourself. This only works when you create a new .html file.
- This would work for other ST2/3 Syntaxes. Just change step 1 to your package of choice if not already installed
- This seems to work fine for ST3 (not tested on ST2)
- Watch out for commas!
- Other details
- If anyone has a better option than this do let me know over @natetronn
You can also use the .twig file extension and Sublime Text will automatically assign HTML (Twig) syntax highlighting to your files.