Adding PHP Twig syntax to Sublime 3

I needed to start working with Twig recently so I had to add syntax highlighting to Sublime for it. Pretty easy and the best tutorial I found was here:

1. Download

The files can be downloaded from

or you can also clone them with:

2. Installation

To install this bundle in Sublime Text, a few extra steps are required.

a) Open Sublime Text and in the Preferences menu click Browse Packages.

b) In the directory that was just opened, create a new directory PHP-Twig/.

c) Copy the content of the repo you downloaded into the directory you just created.

d) Move the contents of the PHP-Twig/Syntaxes/ directory to PHP-Twig/ (one directory up).

e) Restart Sublime Text.

3. Apply

To apply syntax highlighting on your Twig HTML files : Open a .html.twig file Go to View menu → SyntaxOpen all with current extension asHTML (Twig).


28 thoughts on “Adding PHP Twig syntax to Sublime 3

  1. How can I append a value into an array using twig? I tried:
    {% set field.wrapper_attributes = field.wrapper_attributes|merge([‘has-content’]) %} but keep getting:
    “Unexpected token “punctuation” of value “.” (“end of statement block” expected).”

Leave a Reply

Your email address will not be published. Required fields are marked *