Editor highlighting line break when hitting return

Hi,
I have been working with this problem for a few years. I have not found a solution and I cannot get used to it.
Here is what happens...
  • I want to insert a new line of text in the middle of a script.
  • I place the cursor at the end of a line.
  • I hit return to create a new line.
  • Matlab inexplicably selects the line break.
  • When I start typing the line break is overwritten.
  • The new text goes at the end of the old line, instead of at the beginning the new line.
  • This problem happens intermittently.
This never used to be an issue, but it has been a persistent annoyance for the last couple of years. I have tried looking for a solution, but I have yet to find one that works.
I am currently using Matlab R2024a Update 1 on a Mac Studio Apple M1 Ultra running Sequoia 15.5
Please help!
thanks,
Ben

8 Kommentare

Matt J
Matt J am 20 Jun. 2025
Bearbeitet: Matt J am 20 Jun. 2025
Does it happen on other computers? Maybe it's a hardware problem.
dpb
dpb am 20 Jun. 2025
"I place the cursor at the end of a line"
How, specifically, do you reach the end of the line? Does it do it if you use "End" key rather than mouse?
Ben Ward
Ben Ward am 23 Jun. 2025
Hi both,
It may well be an issue with the so-called magic mouse. I have just tried with a wired Dell mouse and I couldn't recreate the issue. Switching back to the Apple mouse it occurred at about the third attempt.
Weirdly though, the issue only happens in Matlab. I don't see it in any other text editor on this machine.
@Matt J I don't know if it happens on other machines, as I only use the one.
@dpb While the problem is intermittent, it looks like it does not happen using 'command+right arrow' (with either mouse).
Thanks,
Ben
dpb
dpb am 23 Jun. 2025
I'd suggest submitting a bug report on the behavior with the precise hardware and software configuration--it's always possible there's something weird in a particular piece of gear or version. Mathworks would likely have to be able to recreate the setup in order to have any chance at all of finding out what might be different there.
Ben Ward
Ben Ward am 24 Jun. 2025
Will do.
Thanks for your help.
dpb
dpb am 24 Jun. 2025
Or, it's always possible there's something funky with your particular one of these mouses...no chance to try another one of them, I suppose, is there?
Ben Ward
Ben Ward am 25 Jun. 2025
Thanks, I will try this.
dpb
dpb am 25 Jun. 2025
Oh, another thought. Have you tried updating a driver for the particular hardware? Maybe there's a fix there for a known issue...

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

K.
K. am 11 Jul. 2025

0 Stimmen

I was able to reproduce this with a Magic Mouse in R2025a and have reported the issue to the appropriate person within MathWorks. I have also referred them to this page in case they have any information to share.

2 Kommentare

dpb
dpb am 11 Jul. 2025
Kewl! to know it was/is reproducible. Be interesting to learn if it is actually a code defect or something non-conformant in the mouse firmware...
Ben Ward
Ben Ward am 14 Jul. 2025
Great that you were able to reproduce this. Thanks for looking into it.
Ben

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Ruchika Parag
Ruchika Parag am 25 Jun. 2025
Hi @Ben Ward, based on your description, it seems like there may be a UI behavior issue in the MATLAB Editor, possibly related to macOS input handling or preferences.
Here are a few things you can try:
1. Check Editor Preferences
Sometimes aggressive auto-formatting or indentation settings can cause unexpected behavior.
  • Go to Home > Preferences > Editor/Debugger > Language.
  • Try disabling Smart Indentation, Auto Formatting, and any related options.
  • Restart MATLAB and test again.
2. Disable macOS Press-and-Hold Behavior
macOS includes a feature that can interfere with how some keys (like Return) behave in applications. You can disable it with this terminal command:
defaults write -g ApplePressAndHoldEnabled -bool false
After running the command, restart MATLAB (and possibly the system) to apply the change.
Hope this helps!

2 Kommentare

Ben Ward
Ben Ward am 25 Jun. 2025
Verschoben: Walter Roberson am 11 Jul. 2025
This did not fix it, so I will try @dpb's suggestion of swapping out the magic mouse.
Ben Ward
Ben Ward am 14 Jul. 2025
Thanks all.
Unfortunately none of the suggestions worked.
all the best,
Ben

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming Utilities finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2024a

Tags

Gefragt:

am 20 Jun. 2025

Kommentiert:

am 14 Jul. 2025

Community Treasure Hunt

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

Start Hunting!

Translated by