Importing/Exporting color themes for the MATLAB editor
Asked Answered
C

2

9

Is there a way (maybe undocumented?) of importing/exporting color themes for the MATLAB editor?

As an example, I would like to import the Zenburn color scheme in MATLAB.

Clipboard answered 9/8, 2011 at 20:17 Comment(0)
C
10

The color settings are saved in the matlab.prf file. You can find its location by running the command:

prefdir

There are a number of lines that start with the word Colors, for example:

ColorsBackground=C-16506839
ColorsMLintAutoFixBackground=C-3454186
ColorsText=C-8153962
ColorsUseMLintAutoFixBackground=Btrue
ColorsUseSystem=Bfalse
Colors_HTML_HTMLLinks=C-7102047
Colors_M_Comments=C-10981771
Colors_M_Errors=C-2346449
Colors_M_Keywords=C-8021760
Colors_M_Strings=C-13983336
Colors_M_SystemCommands=C-7613747
Colors_M_UnterminatedStrings=C-2935166
Colors_M_Warnings=C-27648

You can save those lines as your "theme" and then share them with others. They just have to replace the Colors* lines with yours.

I would recommend opening the matlab.prf file in some text editor and then sorting the lines to make it easier to select only the lines of interest.

Chisel answered 25/8, 2011 at 18:15 Comment(1)
Notepad++ can sort the lines of a text file as explained hereGrot
N
14

I got so annoyed by the lack of a colour scheme/theme import and export facility in MATLAB when trying to move my own custom made theme between my MATLAB installations, I went and made a package which does just this.

The end result, called MATLAB Schemer, is rather comprehensive. In addition to the main colours described in Alexandre Chabot's post, it will also import and export editor colours, the status of toggleable settings such as right-hand line limit and cell mode, and the colours for syntax highlighting in other languages supported by MATLAB (C, C++, Java, XML, HTML, some Simulink things). Additionally, if a MATLAB-only theme is imported, it will be generalised to apply the theme in the other languages too.

It is available on the MATLAB FileExchange and on GitHub.

I implemented a few color schemes myself, but did not implement the Zenburn scheme. Since this post is from a few years ago now, I assume you have long ago resolved your problem of setting MATLAB to use colours from the Zenburn theme. If so, you could create a Zenburn theme by exporting the colour preferences you currently have simply by running schemer_export() in the MATLAB terminal. You could also share it by adding it to the repository of colour schemes.

I hope this is helpful (if not to you than to somebody else at least).

Northamptonshire answered 12/11, 2015 at 16:51 Comment(0)
C
10

The color settings are saved in the matlab.prf file. You can find its location by running the command:

prefdir

There are a number of lines that start with the word Colors, for example:

ColorsBackground=C-16506839
ColorsMLintAutoFixBackground=C-3454186
ColorsText=C-8153962
ColorsUseMLintAutoFixBackground=Btrue
ColorsUseSystem=Bfalse
Colors_HTML_HTMLLinks=C-7102047
Colors_M_Comments=C-10981771
Colors_M_Errors=C-2346449
Colors_M_Keywords=C-8021760
Colors_M_Strings=C-13983336
Colors_M_SystemCommands=C-7613747
Colors_M_UnterminatedStrings=C-2935166
Colors_M_Warnings=C-27648

You can save those lines as your "theme" and then share them with others. They just have to replace the Colors* lines with yours.

I would recommend opening the matlab.prf file in some text editor and then sorting the lines to make it easier to select only the lines of interest.

Chisel answered 25/8, 2011 at 18:15 Comment(1)
Notepad++ can sort the lines of a text file as explained hereGrot

© 2022 - 2024 — McMap. All rights reserved.