View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
extend Matlab Editors callback

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 59.4 KB File ID: #41099 Version: 1.15
image thumbnail

extend Matlab Editors callback



03 Apr 2013 (Updated )

Extends the editor features. Closing brackets, Operator. Templates, Keyboard Shortcuts

| Watch this File

File Information

View README.txt
# Startup
# the startup file creates a edit.m file in specified path (needs to be set) directory.
# you can change this behavior in sturtup.m and edit editPath.
# it will overload the built in edit function.
# and add paths to the appdata of "0"


This file inspired Gavri Yashar/Matlab Editor Plugin.

Required Products MATLAB
MATLAB release MATLAB 8.6 (R2015b)
MATLAB Search Path
Other requirements File ID: #14317 - findjobj
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
02 Aug 2016 Andreas J.

moved to

Comment only
15 Jul 2015 Andreas J.

If you add following code in daEditor.DaEditorCallbacks, the system will search for the expression in your own commands and will print the result out in the command window. e.g.:
%commandwindow output:
TabCompletion on MESRC:
%%%%%%%%% CODE %%%%%%%%%%
if ctrlOnlyFlag && evnt.getKeyCode == evnt.VK_SPACE

aE = matlab.desktop.editor.getActive;

pos = aE.Selection;
pos(2,1:4) = pos;
cursorPos = matlab.desktop.editor.positionInLineToIndex(aE, pos(1,1),pos(1,2));
txt = aE.Text(matlab.desktop.editor.positionInLineToIndex(aE,pos(1,1),1):cursorPos-1);

idx = regexp(txt,'\%');
if isempty(idx); return; end
idx = idx(end); % nearest to cursor
expr = txt(idx+1:end);

mesrPath = fullfile(SDS_ToolPath_DA,'MatlabM\Tools\Matlab_Editor_StringReplacements\Replacements');
oCD = cd(mesrPath);
dirCont = dir('MESRC_*.m');
mesrList = {};
mesrList = mesrList(:);
mesrList = regexprep(mesrList,'MESRC_(.*?)\.m','$1');

mesrListTab = mesrList(util.regexCell(mesrList,expr));
txts = strjoin(mesrListTab,'\n\t');
fprintf('\nTabCompletion on MESRC:')

Comment only
06 Jun 2014 Andreas J.

With the following code you can use CTRL + E instead of CTRL + D to opened selected functions, it automaticly extends the now opened editor also.

ctrlOnlyFlag = ctrlFlag && ~shiftFlag && ~altFlag;
%% CTRL + E
if ctrlOnlyFlag && evnt.getKeyCode == evnt.VK_E
% Ɯberladenes CTRL + D von Matlab
str = daEdit.mEditor.SelectedText;
fprintf('Strg+D: "%s" in "%s"\n',str, char(daEdit.mJavaEditor.getShortName))

Comment only
06 Jun 2014 Andreas J.

BugReport: If you have multiple editors opened (like 30+, depends on your computer) the extend editor function will take a while to finish. e.g. if you use the edit function it can take a while until the "Busy" label is removed from matlabs bottom bar..

This bug will be fixed in a future release.

Comment only
21 May 2014 Andreas J.

I currently use a custom keyboard shortcut to delete the line i'm currently on quite a lot. If you want to use it also add following code in daEditor.DaEditorCallbacks:runShortcutKey

ctrlShiftFlag = ctrlFlag && shiftFlag && ~altFlag;
if ctrlShiftFlag && evnt.getKeyCode == evnt.VK_Y
% remove Current Line - multiple lines at once possible
linSize = numel(daEdit.getTextByLine(daEdit.selection(3)));
if linSize == 0
offS = -2;
offE = -1;
offS = -2;
offE = 0;
posS = daEdit.idx2pos(daEdit.selection(1),0)+offS;
posE = daEdit.idx2pos(daEdit.selection(3),linSize)+offE;


Comment only
30 Sep 2013 Andreas J.

Thanks for your feedback Jonathan Sullivan. I'll look into it as soon as i have time for it!

Comment only
27 Sep 2013 Jonathan Sullivan

This is great. I like the idea. I have a few comments.

First off, there is a somewhat distracting flashing of the editor window when the "+=" type of substitution is occurring. Not a big deal, but it would be nice to fix it.

Secondly, the colorization of the breakpoint bar wasn't working. It couldn't find it by the .getComponent calls you hard coded in. I do have a solution that will dynamically find it. It is below. Notice the change in the number of arguments to the function colorizeBreakPointBar.

function colorizeBreakPointBar(jMainPane,color)
[names, access] = findAllComponents(jMainPane);
a = access(strcmpi(names,'BreakpointView$2'));
for jj = 1:length(a)
inds = a{jj};
this = jMainPane;
for ii = 1:length(inds)
this = this.getComponent(inds(ii));

function [names, access] = findAllComponents(jMainPane,names,access,access_base)

cmps = jMainPane.getComponents;

if nargin == 1;
names = {};
access = {};
access_base = [];

for ii = 1:length(cmps)
c = regexp(char(cmps(ii).toString),'\.([^\[\.]+)\[','tokens');
names{end+1} = c{1}{1};
access{end+1} = [access_base ii-1];

[names, access] = findAllComponents(jMainPane.getComponent(ii-1),names,access,access{end});


names = names(:);
access = access(:);

Comment only
15 Apr 2013 Jan Simon

Jan Simon (view profile)

An overloaded function is used, when its folder appears before the folder of the original file in Matlab's PATH. Therefore moving a folder temporarily to the first position on the PATH is sufficient to shadow a function of Matlab's toolboxes. See "addpath" without the recommended '-end' flag.

For this reason the '-end' flag is such essential: When you create a damaged function, which shadows an important function like PATH, EDIT, STRCMP etc, it could happen, that you cannot start Matlab to fix this problem.

Comment only
08 Apr 2013 Andreas J.

AFAIK to overlod a function, the function new function need a higher folder level. And the edit function is in matlabroot. so if you don't have write acces to the matlab root folder you need to start this tool manually.

I would be very pleased if anyone can proof me wrong. It would be veryhelpfull to know another way to overload functions

like @overload \path\morepath\somemore\andmore\myFunc.m

Comment only
08 Apr 2013 Jan Simon

Jan Simon (view profile)

This is a very good idea in general. I had some automatically closing parenthesis in my Alpha editor on the Mac 20 years ago already.

In the startup.m file, you expect the user to have write privileges in the matlabroot folder. This is not a smart idea.

Comment only
05 Apr 2013 1.1

Changed: Tested Releases

05 Sep 2013 1.3

operatoren support
+=, -=, *=, /=

06 Sep 2013 1.4

better regexp for variable finding

09 Sep 2013 1.5

bugfix variable match

23 Sep 2013 1.6


25 Sep 2013 1.7

Breakpointbar is colorized to show that this feature is enabled.

12 May 2014 1.8

* Supports usermade replacements
* Bug fixed reported by Jonathan Sullivan

12 May 2014 1.9

updatet description

19 May 2014 1.10

* Script Templates Variables
      * Keyboard shortcuts
      * some replacements caused still a flashing bug. should now be completely removed

19 May 2014 1.11

forgot to update summary
* Extends the editor features. Closing brackets, Operator. Templates, Keyboard Shortcuts

02 Jul 2014 1.12

* added Advanced replacement tool
      * added GUI for templates
      * fixed bug "multiple editors open"

16 Oct 2015 1.15

V0.10 * several fixes
      * IntelliJ like Filestructer Browser
      * made it easier to "install" extended editor

09 Sep 2016 1.15


26 Sep 2016 1.15

link to new project

Contact us