Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write my own syntax highlighting for gtksourceview. If it's done it should highlight guitar chords in a text file. This is my unfinished file:

<?xml version="1.0" encoding="UTF-8"?>
<language id="tab" _name="Tab" version="2.0" _section="Others">
    <property name="mimetypes">text/plain</property>
    <property name="globs">*.txt;*.tab</property>

    <style id="chord" _name="Chord" foreground="blue" bold="true"/>


    <context id="chord" style-ref="chord" class="no-spell-check">

    <context id="tab">
        <context ref="chord"/>


I would expect every capital A to H to be blue and bold in the highlighted text. Is saved the file to /usr/share/gtksourceview-3.0/language-specs and I am able to select it in GEdit. But nothing is highlighted in the text.

Can anyone tell me what I am doing wrong?

share|improve this question
up vote 2 down vote accepted

Turns out I can't define the style in the .lang file. In the <style> tag there I can only refer to a style that is defined in the files in /usr/share/gtksourceview-3.0/styles. E.g. to the style used for keywords in programming languages:

<style id="chord" _name="Chord" map-to="def:keyword"/>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.