How do I install a MATLAB mode in GNU Emacs?

Bob Cross picture Bob Cross · Sep 2, 2009 · Viewed 13k times · Source

Is there an Emacs major mode for MATLAB and / or Octave files? For those who don't know, MATLAB files generally have a ".m" file extension.

My primary interest is GNU Emacs but XEmacs tips would also be appreciated.

Answer

rplevy picture rplevy · Sep 2, 2009

Have you tried the octave-mode that is part of the standard emacs distribution? I have found that this works well.

If you're finding it doesn't associate the .m extension, add this to your .emacs:

(setq auto-mode-alist
      (cons
       '("\\.m$" . octave-mode)
       auto-mode-alist))