MATLAB: Bug with external editor – How to override opentoline – Matlab 2011b – Open file to line in external application

external editorMATLABopentoline

Hi
In preferences/Editor, I set up an external editor command for use with vim. Running "edit Filename" opens the desired editor. Yet, with Matlab R2011b on Linux, by clicking on a "error link with specific line" in the command windows it opens a matlab editor instead of the external editor. Hovering the mouse over this link displays: "matlab: opentoline('…',xx,xx)" in the taskbar.
In previous versions (e.g. R2010b) I used to override the function "opentoline.m" by putting a different version in my own path. In matlab R2011b on Linux, it seems the script "opentoline.m" is not called anymore, though still present within the matlab folder: /toolbox/matlab/codetools/.
Thank you for your help.

Best Answer

The support team told me that opentoline was now directly called through java.
I found a way to get a similar behavior by overring the function errorDocCallback.m (in toolbox/matlab/helptools/+HelpUtils).
In this way, clicking on the filename will open the external editor at the right location.
A code like the following does the job:
editor = system_dependent('getpref', 'EditorOtherEditor');
editor = editor(2:end);
linecol = sprintf('+%d',lineNumber);
cmd=[editor ' "' linecol '" "' fileName '" &'];
system(cmd);