Re: [gedit-list] customize script highlighting by file extensions



Hi,

Max Chalfin a écrit le 2011-09-21 10:45 :
> I find that gedit does not automatically recognize certain file
> extensions for highlight mode.  In particular it does not know that
> *.r should be highlighted as an R script.  I would like to fix this,

Strange. Language definition for R can be found here (note: I don't know
if paths are different on FreeBSD; below I'll use paths on Ubuntu):

/usr/share/gtksourceview-2.0/language-specs/R.lang

This file contains information to highlight R files, among others file extensions:

<property name="globs">*.R;*.Rout;*.r;*.Rhistory;*.Rt;*.Rout.save;*.Rout.fail</property>

For example, according to the line above, the following files will be
automatically highlighted as R files:

my-file.R
my-file.Rout
my-file.r
my-file.Rhistory
my-file.Rt
my-file.Rout.save
my-file.Rout.fail

So in theory, if there's no bug, *.r should be automatically highlighted.

> as well as add my own file extensions for shell scripts, and not be
> limited to *.sh.

You can copy the following file:

/usr/share/gtksourceview-2.0/language-specs/sh.lang

and paste it on the following emplacement (create folders if they don't
yet exist):

/home/YOU/.local/share/gtksourceview-2.0/language-specs/

Then, find the line corresponding to the extensions, something like:

<property name="globs">*.sh</property>

and add your own extensions, for example:

<property name="globs">*.sh;*.sh1;*.sh2</property>

> Furthermore, I have found that the shell scripting highlight mode recognizes bash syntax but not tsch.  Can this be customized?

Yes. Open the above file used to custom shell language:

/home/YOU/.local/share/gtksourceview-2.0/language-specs/sh.lang

There are various sections about the language definition. You can customize
them or add others. Explanations can be found here:

http://live.gnome.org/Gedit/NewLanguage

Regards,

Jean-Philippe


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]