mapserver syntax file for gedit

Gedit is my editor of choice at the moment, but, with all it’s great plugins, it was kinda lacking when working with Mapserver map files. So far vim, textpad and notepad++ have syntax support for map files, and now I’m happy to announce, Gedit does!

gedit syntax for mapserver map files

There’s a bit of tweaking to get it working.

1. First, we need to tell gnome to associate the .map file with the syntax, by giving it it’s own mime-type (you could skip this, but then you would need to manually select the highlighting mode for each file).

Download this file: http://geothings.net/thinkwhere/mapserver/mapserver.xml and copy it to /usr/share/mime/packages/ directory

Then, update Gnome’s mime database:

$ sudo update-mime-database /usr/share/mime

2. Next download the syntax lang file: http://geothings.net/thinkwhere/mapserver/map.lang and copy it to the /usr/share/gtksourceview-1.0/language-specs directory (or gtksourceview-2.0 if you are using Gutsy)

3. Restart gedit, open up a .map file and voila!

Thanks to the vim, notepad++ and texpad syntax files that I used to write this. Tested with Ubuntu 7.04 (Fiesty) and gedit 2.18.1 – let me know if it works, or doesn’t with Gutsy.

For Gutsy, gtksourceview2.0 .lang files have a different syntax – but it is meant to work with 1.0 version files. There’s also a conversion utility convert.py that could help.

EDITS: See comments for a way to get it working with Gutsy, thanks Michal!

7 thoughts on “mapserver syntax file for gedit

  1. Really nice work. Hovewer i was unable to make it work under Gutsy. I don’t know how to convert the file using convert.py (Your link produce internal server error) so i ended doing it less elegant way. But it works. I simply added in /usr/share/gtksourceview-1.0/styles/classes.xml three more lines:

  2. Ech, sudden stupidity? <style name=”String” foreground=”magenta”/>
    <style name=”Data Type” foreground=”green” bold=”true”/>
    <style name=”Keyword” foreground=”bordeaux” bold=”true”/>

Leave a comment