Save the file names and layout of currently open files in the matlab editor as a project workspace session. Different sessions can be saved and loaded.
I often group open files in different tiles in the editor. Switching from Matlab 2008b to 2013b the files from the last time I used matlab would open, but no longer in the correct place in the editor. This submission is the result of 'fixing' the problem also allowing you to open not just what was open last time (if the session was saved), but any set of files from a saved session.
A session also saves the current folder in Matlab (present working directory) and opening a session will automatically change the current folder to it. This lets you open sessions with files in completely different locations while changing the present working directory automatically as well. There is also an option to automatically add sub folders to the path when saving/loading a session. I group files based on similar functions as if it were a package, and adding sub-folders to the path allows me to keep files organized without requiring the naming complexity of packages.
Save the zip file and unzip to the matlab path. Make sure that they are placed on the user path so that matlab can find them when first opened (allowing shortcuts to work). Running 'editorLayout.copyFilesToUserPath()' should do this automatically for you if you don't want to deal with it yourself.
'editorLayout.createShortcuts()' will add shortcuts to load, save, and manage editor sessions in the shortcuts bar. I then manually edit these shortcuts (right click-edit) to add them to my quick access toolbar and choose different icons for them (I choose the M, L and S for Manage, Load and Save).
You can also use the command line directly by calling any of:
The editor sessions, files, and layouts are stored in an xml file in the preferences directory prefdir named 'savedEditorSessions.xml'.
-Datatips don't seem to appear anymore in the editor (e.g. variable values: can still highlight then press F9 to see value; Code anlyzer warnings/error messages: right click or click or click and press Ctl-M to get the message to appear when hovering over the underlined text)
-The way the layout is restored breaks some functionality in the editor:
Hovering over the tile splitter square doesn't bring up the little x to merge tiles. Workaround: right clicking on it will give you an option to do the same.
-Sometimes dragging files to different tiles after loading a session will leave a blank tile. Work around: put a different file there, or move files to adjacent tiles where there is a tile splitter between them that can merge them.
Marshall (2021). Editor Session Manager (https://www.mathworks.com/matlabcentral/fileexchange/46352-editor-session-manager), MATLAB Central File Exchange. Retrieved .
Extremely useful tool. Thank you! It would help if the menu was graphical.
Using in Matlab R2017a and Windows10 and works nicely.
I will report if I find some problem.
At the moment it has been of great help to save not only the files of a session but also the displacement of all panels.
I have solved my problem by inserting the command "commandwindow" at relevant locations in the "SessionEditor.m" file.
@Marshall, I can provide files if you would like to provide update to other users.
Very useful, just what I was looking for.
One small issue, when you try to load a profile by entering a number in the command window, the editor has context not the command window. Is there any way to solve this?
this is great, thanks!
Very useful! Seems to be working well on R2017b, Linux.
Only tried a little bit so far, R2017a and Windows10 -- but seems to work great so far!
It seems there is an issue if the file was Read-Only.
I get something like:
Warning: File "D:\...\mfile.m [Read Only]" not found.
Should this file be removed from the session [y/n]?
I would ignore wether the file is Read-Only or not.
With the latest update createShortcuts doesn't copy files to user path by default as Thierry Dalon suggested.
As for backward compatibility and use of tables: doing this without tables should be possible. I'll see what I can do. However, there is un-documented Matlab code in here that I won't have any way of knowing for sure it will work with other versions unless other people can verify it for me or find the equivalent commands.
I would not double copy the files into the userPath by creating the shortcuts.
I just want to have to ensure that the files are on my Path (where I want) to be able to run the shortcuts.
It seems you can not open a session with an older Matlab version because you are using Tables?
I get the error:
Undefined function 'table' for input arguments of type 'cell'.
Error in editorLayout.SessionEditor/getSessions (line 231)
T = table(index,name,numFiles,currentFolder,addPaths,lastUsed,lastSaved);
Inspired by: SaveCurrentEditorFiles
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!