How to Set Syntax Highlighting in Gedit – Customization Tips

geditsyntax highlighting

For some godforsaken reason, Twig files in our source code are saved with a .html extension, instead of a .twig extension. I followed guidelines to add custom highlighting to Gedit, and the Twig highlighter I found does attach to .html files (with <property name="globs">*.twig;*.html;</property>). However, the inbuilt HTML highlighter also attaches to .html files (with <property name="globs">*.html;*.htm</property>). This is the ruleset that Gedit uses for .html files (possibly because html.lang is earlier alphabetically than twig.lang).

I don’t often edit either HTML or Twig, so I don’t need some sort of automated solution which works out what type of file it really is and applies the correct highlighting. Picking the highlighting from a Preferences menu would be sufficient. Is there any way to do that?

Basically, when I open a .html file, I want a way to tell Gedit that this file is actually Twig.

Best Answer

Yes you can go to

View -> Highlight mode -> Select which one you need