View Full Version : gedit syntax highlighting - adding a new type

November 1st, 2008, 11:16 PM

I'm a recent linux convert running Ubuntu 8.04 with gnome and trying to create a new syntax highlighting file for gedit. I'm doing some work with MIPS assembler; enough that highlighting would be useful. I've seen similar in vim, but would prefer to use gedit. I've read various posts, which led me to create a mips.lang definition file (attached) and drop it into /usr/share/gtksourceview-2.0/language-specs. I created it based on content from other language spec files I found there. I also created a mips.xml file and dropped it into /usr/share/mime/packages and then ran update-mime-database.

I've seen in other posts that an x-asm.xml file may be required in /usr/share/mime/text, but I've no idea how to create that file, or if it's really necessary.

Based on the changes I've made gedit does recognize the *.asm files when I open them, but does not do any highlighting for some reason. I'm guessing that either my language definition file is somehow flawed, or that I'm missing some crucial step. Any suggestions or help would be greatly appreciated.


March 8th, 2009, 11:47 PM
I have been doing some programing for class using SAL (simple abstract language), which I think is what you are looking for. I have been using gedit to do so. Here is my lang file that does some simple coloring for me.

Copy the code below into a file named:

or rename the attched doc (remove the .txt) and place it there.

This is the path for Ubuntu 8.10, I also noticed there was a gtksourceview-1.0, but placing it in there had no effect.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--Created using the CPP.lang file as a template-->
<language _name="SAL" version="1.0" _section="Sources"


<line-comment _name = "Line Comment" style= "Comment">

<block-comment _name = "'#if 0' Comment" style = "Comment">
<start-regex>^[ \t]*#[ \t]*if[ \t]*0</start-regex>
<end-regex>[ \t]*#[ \t]*(endif|else)</end-regex>

<string _name = "String" style = "String" end-at-line-end = "TRUE">

<keyword-list _name = "Keywords" style = "Keyword" case-sensitive="TRUE">

<keyword-list _name = "Types" style = "Data Type" case-sensitive="TRUE">

<string _name = "Character Constant" style = "String" end-at-line-end = "TRUE">

<pattern-item _name = "Decimal" style = "Decimal">

<pattern-item _name = "Floating Point Number" style = "Floating Point">

<pattern-item _name = "Octal Number" style = "Base-N Integer">

<pattern-item _name = "Hex Number" style = "Base-N Integer">


I hope this helps. Please post your file if you have any improvements.:-D

May 6th, 2009, 01:36 PM
I have also made files for MAL and TAL. I am sure this is only useful for students that are programing in these languages, but here you go.

June 18th, 2009, 11:30 AM

any news on this? I need MIPS assembler syntax highlighting, too. It would be great, if it would work with gedit.

Thanks a lot for any response.

June 18th, 2009, 01:35 PM
I know that the KATE (http://en.wikipedia.org/wiki/Kate_(text_editor)) text editor has highlighting for MIPS. Just install it through package manager. On KATE's menu just goto Tools-> Higlighting -> Assembler-> MIPS Assembler.

June 18th, 2009, 02:14 PM
You can use the code above for the MIPS. Just pick which format (most likly SAL) that you will be coding with. If there is something missing, let me know.

June 10th, 2010, 06:06 PM
I tried to write my custom syntax highlighting file for Gedit as well, and have the same problem:
- Since the target syntax is similar to VB, I duplicated the vbnet.lang in /usr/share/gtksourceview-2.0/language-specs and renamed itgl
- I changed the id, name, category(scripts), file-extension but not the mimetype
- I removed/added some keywords, no major changes to the XML structure itself...

Under View>Highlight>Scripts my custom syntax definition shows up, but when I choose it, no styles are applied! How can I make sure the styles are used? I am curious, because even though I made an exact copy of the VB-definition, just changing id and file extension, gedit stops applying any style to my code...