I'm using emacs for editing a bunch of matlab files. The only gripe that I have is that the syntax highlighting provided by octave-mode is pretty poor.

This is the syntax highlighting provided by sublime text, while this is emacs. On the right side is octave-mode, on the left is matlab-mode.

How can I have syntax highlighting for the keywords and numbers in emacs?

EDIT: I just found highlight-numbers-mode for the numbers, the only problem left is the keywords highlighting.

  • As a side note (if you're into this kind of thing) you can also have semantic highlighting of identifiers with rainbow-identifiers-mode. – ngmir May 25 '20 at 7:35

octave-mode does have some keywords (see source). Even so, you can add your own:

(font-lock-add-keywords 'octave-mode
                        '(("\\<load\\>". font-lock-keyword-face)                                                                                                                           
                          ("\\<clear\\>". font-lock-keyword-face)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.