Erlang Syntax Highlighting

I have written a language definition file for GtkSourceView to get a nice syntax highlighting for Erlang with applications that use this component, e.g. Gnome’s standard editor gedit.

The highlighting looks like this:

Screenshot gedit with Erlang sourcecode

Here is how to get this to work:

Install Erlang Language File

  1. Download the file erlang.lang.
  2. Copy the file to /usr/share/gtksourceview-1.0/language-specs/erlang.lang.
  3. Start gedit, open an Erlang file, and choose View > Highlight Mode > Sources > Erlang.

Automatically Recognize *.erl

If you want gedit to automatically recognize that all .erl files should be correctly highlighted, you have to define the mime type (more info is here):

  1. Create directory to override mime types, in the command line type
  2. Download the custom mime file Override.xml into this directory (if the file already exists, you have to copy the relevant lines by hand):
  3. Update the mime database by merging the file:
  4. Restart nautilus (or logout & login again):

There you go, Erlang code in all its glory. Happy hacking!

6 Comments on "Erlang Syntax Highlighting"

Notify of

Martin Ankerl
8 years 8 months ago

The highlighting has one known bug: it cannot handle $” or $’ correctly. I don’t know how to fix this problem, can anyone help?

Martin Ankerl
8 years 7 months ago

Freedesktop has just added the mime type, which is the requirement for gtksourceview to add the highlighting file.

8 years 6 months ago

Thanks a lot!

That’s what I’ve wished for!!!

Cheers, Mathi

P.S.: Maybe put it on cean? It took me a while to find it…


[…] Here’s a good recipe for syntax highlighting for gedit. […]

5 years 4 months ago

There’s a slight bug with the module attribute highlighting; colors were spilling over into the parens and first char of the value field. I was able to fix by replacing the original module atttribs section with this:


Note the only difference is the sub of a ‘\b’ for the original ‘\B’. I copied this essentially from the function highlighting section.

5 years 4 months ago

…sorry, included XML in the above post that isn’t displaying, but you get the idea.