Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating your own syntax highlighting in GEdit?

Tags:

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"); 
like image 938
Kredns Avatar asked Apr 20 '09 03:04

Kredns


People also ask

How do you highlight text in gedit?

If gedit recognizes the syntax being used when you open a file, it will automatically highlight the text. If your syntax or language is not highlighted upon startup, you can select the appropriate syntax or language by clicking View ▸ Highlight Mode, and then choosing the desired syntax.

What is syntax highlighting style?

Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.


2 Answers

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.

like image 134
Paige Ruten Avatar answered Sep 21 '22 13:09

Paige Ruten


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)

like image 28
Michael Clerx Avatar answered Sep 23 '22 13:09

Michael Clerx