Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twig syntax highlighting sublime text

I want to know how can I have highlighting syntax for TWIG in Sublime Text.
Actually when I open a TWIG file all fonctions and conditions are similar (white on black) :
Screenshot SublimeText2

like image 716
Antoine Subit Avatar asked Oct 10 '14 07:10

Antoine Subit


2 Answers

You can also install PHP-Twig.tmbundle through Sublime Text's Package Control.

With Package Control installed:

  1. Go to PreferencesPackage ControlInstall Package
  2. Type "Twig", and select PHP-Twig.

It will install the same version of @antoine-subit's answer, and will automatically use the correct syntax for any Twig file you open

like image 24
afarrapeira Avatar answered Oct 05 '22 10:10

afarrapeira


Documentation

Syntax highlighting and auto-completion for Twig in Sublime Text 2
is possible with : PHP-Twig.tmbundle

  • TWIG Doc "IDEs Integration" : http://twig.sensiolabs.org/doc/templates.html#ides-integration
  • Bundle's Github : https://github.com/Anomareh/PHP-Twig.tmbundle
  • Bundle's Documentation : https://sublime.wbond.net/packages/PHP-Twig

Download

You can clone the project with :

git clone https://github.com/Anomareh/PHP-Twig.tmbundle.git 

Or download it directly from the Github (last master version) :
https://github.com/Anomareh/PHP-Twig.tmbundle/archive/master.zip

Installation

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

  1. Open Sublime Text and in the Preferences menu click Browse Packages.
  2. In the directory that was just opened, create a new directory PHP-Twig/.
  3. Copy the content of this repo into the directory you just created.
  4. Move the contents of the PHP-Twig/Syntaxes/ directory to PHP-Twig/
  5. Restart Sublime Text.

Apply

To apply syntax highlighting on your Twig HTML files :

  1. Open a .html.twig file
  2. Go to View menu → SyntaxOpen all with current extension asHTML (Twig)

That’s it. It should work by now.

Happy Coding!

Screenshot

Twig syntax highlighting sublime text 2

like image 188
Antoine Subit Avatar answered Oct 05 '22 10:10

Antoine Subit