I need to add a new language in Gedit. The problem is, it is included in Gedit menu of languages now, but its syntax is not highlighted and Gedit is not able to indentify the language just from the file suffix.

I've created both .lang file and a XML file describing MIME-TYPE.

LANG file - /usr/share/gtksourceview-3.0/language-specs/test.lang
MIME-TYPE file - /usr/share/mime/packages/test.xml

After creating them I've updated the mime database.

sudo update-mime-database /usr/share/mime

Next attempts

1) I've tried even copying test.xml file to /usr/share/mime/applications folder instead of /usr/share/mime/packages, but it had no effect.

2) I've tried to put the mime type into the /etc/mime.types as

text/x-test test

and it had no effect too.


<?xml version="1.0" encoding="UTF-8"?>
<language id="test" _name="Test" version="1.0" _section="Source">
        <property name="mimetypes">text/x-test</property>
        <property name="globs">*.test</property>
        <property name="line-comment-start">//</property>
        <property name="block-comment-start">/*</property>
        <property name="block-comment-end">*/</property>

       <style id="comment" _name="Comment" map-to="def:comment"/>
       <style id="keyword" _name="Keyword" map-to="def:keyword"/>

        <context id="if0-comment" style-ref="comment">
            <context id="if-in-if0">
                <context ref="if-in-if0"/>
                <context ref="def:in-comment"/>
            <context ref="def:in-comment"/>

        <context id="keywords" style-ref="keyword">

        <!--Main context-->
        <context id="test">
                <context ref="if0-comment"/>
                <context ref="keywords"/>



<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info" >
  <mime-type type="text/x-test">
    <sub-class-of type="text/plain"/>
    <comment xml:lang="en">TEST language document</comment>
    <comment xml:lang="cs">Dokument v jazyce TEST</comment>
    <glob pattern="*.test"/>
  • Your <definitions> block lacks the main <context id=test"> to start with. As per the docs - scroll down to <definitions>: Here we should define a main context, the one we enter at the beginning of the file[ ...] with an id equal to the id of the <language> element Jul 2, 2015 at 17:30
  • @don_crissti I've added the main context, but the problem still lasts :-(
    – Eenoku
    Jul 2, 2015 at 18:38

1 Answer 1


Finally I've figured it out. According to GTK lang reference version attribute in <language> tag should be 2.0. And it's really working.

So, the proper <language> tag is this:

<language id="test" _name="Test" version="2.0" _section="Source">

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .