multiple line edit is not allowed on MATLAB file editor window?

Hi,
Emacs, Sublime text and Visual studio, etc. They all have multiple line edit.
If you do not know what I mean, please see this video at : https://www.youtube.com/watch?feature=player_embedded&v=qp2WuJ2rEE4
Can we do that?

9 Comments

I don't know anything about multiple line editing, but if you prefer you can change the default Matlab Editor to be anything you please, e.g. Emacs, in the Preferences
Well, I don't know it by that description but why don't you tell us what you mean instead of expecting us to go somewhere else?
I cannot believe that such a useful feature is not implemented in Matlab editor. It is really a shame! And going on a different text editor it's only a workaround, not a solution.
@dpb: Taekyu Shin explained perfectly what "multiple line edit" stands for: with a video!
And that is by far the best explanation one could give. But anyway: this is a textual description, if clicking on a link had given you some troubles.
Multiple line edit is the feature that allows you to select a slot of text spanning different lines (usually with Alt+click key) so that they can be modified alltogheter. Usually also multiple-cursors-on-different-columns is supported so that the multiple cursors are not forced to lay on the same column.
A nice video should have work better... but this would have forced you to go "somewhere else". Poor...
I would love for Matlab to support this feature. Please implement it soon.
In release R2018a, the Live Editor supports selecting and editing a rectangular area of code.
It would be a killer feature if implemented in the Matlab Editor, thank you!
It really would be a very useful feature!
please consider it in future releases.
In new-enough MATLAB releases, the traditional editor has been replaced by the live editor, so rectangular editing is now supported.
In case someone stumbled on this thread, following is the exact answer on how to do it. Note the use of mouse with alt and not keyboard (unlike usual editors).

Sign in to comment.

Answers (4)

I would upvote 1billion times this question. Matlab is a so powerful tool that is really becomed lame for its lacking-features Editor.
Together with multiediting, it lacks also of the "duplicate line" feature.
@dpb: Follows a textual description: "Duplicate line" feature allow to duplicate the line you are on, usually pressing Ctrl+D. e.g.
disp('I like textual descriptions')
... pressing Ctrl+D while the cursor is on that line gives
disp('I like textual descriptions')
disp('I like textual descriptions')
Please, don't ask us why this feature is "really useful".

1 Comment

In Brief, numeric keypad '+' copies the current line to buffer and then numeric keypad 'Insert' pastes that buffer (line). Unfortunately for me, the Brief emulation in VS is incomplete and some keystrokes aren't allowed to be remapped at all so it's pretty-much useless.
My question before wasn't anything about whether whatever was/wasn't useful; simply didn't recognize the desired functionality by the description. And, it's certainly much quicker to simply read a simple description than have to go watch a video...and if it takes a video to explain it, I don't care enough and undoubtedly don't use it so don't have anything to add! :)

Sign in to comment.

Dear Mathworks,
Any update on this feature request please!
Thank you!
The MATLAB Editor does not have this, I think. Do you have an example MATLAB source file you can share with us where this kind of thing would be really useful to have?

4 Comments

The fact that vast majority of text editors has this feature should be enough to support the thesis that IS a useful feature.
Sure enough, it's not something that one cannot replace with tons of Ctrl+C Ctrl+V.
The video provides all the details, but anyway:
body1ref_glob = [1;0];
body2ref_glob = [0;1];
body3ref_glob = [1;1];
body4ref_glob = [2;1];
rotLG = [1, 0; 0, -1];
can you please write for me:
body<n>ref_loc = rotLG*body<n>ref_glob;
with multi-edit:
  1. multi-select body<n>ref_ that spans over 4 rows, copy&paste
  2. write loc after that (this will be done automatically on all the 4 new rows)
  3. copy&paste rotLG
  4. multi-select body<n>ref_glob, copy&paste
  5. press ; (this will be done automatically on all the 4 new rows)
Quote: "Do you have an example MATLAB source file you can share with us where this kind of thing would be really useful to have?"
LOL... every MATLAB file I've ever written in over the last 13 years of my career! I end up using Visual Studio Code or Notepad++ to end my MATLAB scripts because the MATLAB editor is awful. And not just because I can't multi-line edit.
Here's another example. Pretend I have the following lines and don't get hung up on having "myElementA" twice.
myBus.mySubBus.myElementA = 2.0;
myBus.mySubBus.myElementB = 3.0;
myBus.mySubBus.myElementA = myBus.mySubBus.myElementB;
If I singe left click myBus, the editor will highlight all four instances of myBus, because it's atthe begining of the line.
But if I single click on mySubBus, the editor is too stupid to recognize that this is used in four places and highlight all of them. Also true for myElementA and myElementB.
Other editors do this and make editing so much easier; MATLAB's editor is like using hammer and chissle.
The most common use I can think of for this feature would be to suppress multiple lines of code with a ;. During development, I leave many lines unsuppressed to make sure the output is what I expect. If I then tidy up my code, I have to spend quite some time inserting ; everywhere. With multi-select this would be a piece of cake.
I have one - when I need to change the same parameter in multiple scenarios simultaneously on different lines. Please check the attached file. I can use search and replace but the feature of editing multiple lines simultaneously is more handy - I use Sublime for this purpose at the moment. Also I would like to note that the attached example file is the small one, sometimes such files can contain up to fifty or more lines of configurations.
It would be great if such feature will appear in Matlab.

Sign in to comment.

Please note that the MATLAB Editor has this feature as of R2021b. You can hold "Alt" or "Option" while clicking to make a multi-cursor block selection. Please see the "Edit and Format Code" section of the documentation for more information.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Asked:

on 23 Oct 2015

Answered:

on 25 Aug 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!