12

Everytime I open a .m file, gedit associates Octave highlighting to it. I would like to change the default behavior to Matlab.

How can I, in general, change the default highlighting that gedit gives to a file associated to one extension to another language?

adn
  • 251
  • 5
  • 23

1 Answers1

5

You could change /usr/share/gtksourceview-3.0/language-specs files but instead copy this file to your home or you will lose changes on upgrade.
$ cp /usr/share/gtksourceview-3.0/language-specs/octave.lang ~/.local/share/gtksourceview-3.0/language-specs/
change
<property name="globs">*.m</property>
to
<property name="globs"></property>

I also did some experimenting and found out objc.lang file also has the same line so you maybe need to copy and change that too.

  • Is there a more nicely way of doing it. Like configure the precedence of the languages, instead of disabling octave? – adn Sep 30 '13 at 13:18
  • What do I do after copying to $HOME dir? How do I tell gedit that it needs to look at the new file xyz.lang in $HOME??? Thanks in advance. – Srikrishnan Suresh Mar 13 '18 at 07:27
  • Note that in modern versions of gedit (e.g. gedit 3.34.0 on Ubuntu 19.10) the correct directory is ~/.local/share/gtksourceview-4 . – Adam Dingle Feb 17 '20 at 16:22