25

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");
Kredns
  • 36,461
  • 52
  • 152
  • 203
  • https://superuser.com/questions/353391/custom-gedit-syntax-highlighting-for-dummies/354684 – Adam Mar 23 '19 at 18:16

2 Answers2

37

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.

Paige Ruten
  • 172,675
  • 36
  • 177
  • 197
  • 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... – stian Mar 18 '13 at 11:14
  • 1
    I made a copy of c.lang and renamed it into proglang.lang, changed into . 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? – 絢瀬絵里 Aug 05 '14 at 05:26
  • sudo gedit /usr/share/gtksourceview-3.0/language-specs/c.lang – Adam Mar 23 '19 at 16:27
10

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)

Michael Clerx
  • 2,928
  • 2
  • 33
  • 47