Creating your own syntax highlighting in GEdit?
Asked Answered
M

2

26

How do you add a 'keyword' to the GEdit list of keywords? I basiclly want to make the printf function look like a keyword.

printf("Hello World\n");
Macaronic answered 20/4, 2009 at 3:27 Comment(1)
superuser.com/questions/353391/…Swastika
F
38

GEdit uses GtkSourceView for its syntax highlighting. You should be able to find the c.lang file it uses to highlight C code by typing a command like this:

$ locate gtksourceview | grep /c.lang

Once you find the lang file, open it up in a text editor (it's an XML file) and near the bottom you'll see a list of keywords which you should be able to add printf to.

Fucoid answered 20/4, 2009 at 3:36 Comment(3)
do you know if this file is also named c.lang in gedit for mac? It should be, but when I searched for this file in finder nothing was found...Evaleen
I made a copy of c.lang and renamed it into proglang.lang, changed <language id="c" _name="C" version="2.0" _section="Sources"> into <language id="proglang" _name="ProgLang" version="2.0" _section="Sources">. While it shows up in the menu, it won't highlight anything. Why is that? Is there some registry like thing needed to be done here?Sulfapyridine
sudo gedit /usr/share/gtksourceview-3.0/language-specs/c.langSwastika
M
11

Thanks to Jeremy's post I found this page: Projects/GtkSourceView - GNOME Wiki! or GtkSourceView - Documentation (from Wayback Machine)

Here you'll find a link to both a tutorial and the official reference for the language definition files.

update: Another useful link Gedit/NewLanguage - GNOME Live! (from Wayback Machine)

Monophony answered 8/2, 2012 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.