Ubuntu – How to change the default highlighting of gedit for a specific extension

geditsyntax highlighting

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?

Best Answer

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.