Colour highlighting GNUPLOT code in gedit.

Gedit by default show colour highlighting for the gnuplot code. But we can easily make it. We just have to download the language definition file and copy to the proper folder. The language definition file is a .lang file. You can download the gnuplot language definition from the following linke.
Download the file and copy the file to the folder /usr/share/gtksourceview-2.0/language-specs/. You can use the following command
$ sudo cp /your/download/location/gnuplot.lang /usr/share/gtksourceview-2.0/language-specs/ 
Now if you open any gnuplot code file with gedit you can see all the colours.
But there is a problem, it will show colour highlight only for those file having extension .plt, but gnuplot can have extension .gp also. So to add .gp also in colour highlighting you have to add one line in the .lang file. If you check the file carefully you can see that there is a protion like this.
<language id="gnuplot" _name="GNUplot" version="2.0" _section="Scientific">
  <metadata>
    <property name="mimetypes">text/x-gnuplot</property>
    <property name="globs">*.plt</property>
    <property name="line-comment-start">#</property>
  </metadata>
Here you can see there is only one file extension specified that is *.plt ( <property name="globs">*.plt</property> ) you can just add following line after that line: <property name="globs">*.gp</property>. So the whole code look like this:
<language id="gnuplot" _name="GNUplot" version="2.0" _section="Scientific">
  <metadata>
    <property name="mimetypes">text/x-gnuplot</property>
    <property name="globs">*.plt</property>
    <property name="globs">*.gp</property>
    <property name="line-comment-start">#</property>
  </metadata>
If you are editing the file directly from the folder /usr/share/gtksourceview-3.0/language-specs/ then you can use the following command:
$sudo gedit /usr/share/gtksourceview-2.0/language-specs/gnuplot.lang
Or you can directly edit the file where you have downloaded and then copy to the proper folder.
Cheers
A.Paul
 

Comments

  1. The dir '/usr/share/gtksourceview-2.0/language-specs/' didn't exist in my system, so I copied the .lang file to '/usr/share/gtksourceview-3.0/language-specs/'.

    Also, the file must be readable for everyone. That may be achieved using 'sudo chmod og=+r /usr/share/gtksourceview-3.0/language-specs/gnuplot.lang'.

    Cheers,
    Clebson

    ReplyDelete

Post a Comment

Please dont forget to tell me if this post helped you or not...

Popular posts from this blog

Changing caption width in latex

Subtitle in latex

Send in Email in Background in Thunderbird