Franck Dernoncourt
Franck Dernoncourt

Reputation: 83157

How can I change the behavior of the commenting function so that the location of the % respect the indentation?

When I comment the line 5 using ctrl+R or clicking on the "comment" icon:

enter image description here

I get: enter image description here

I would like to have instead: enter image description here

How to achieve that?

Upvotes: 7

Views: 114

Answers (1)

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21563

This is not a full solution, but a workaround for low levels of indentation.

  1. Apply all your comments
  2. Use the auto indentation button

The comment will now be at the right place, but unfortunately the space after the comment stays intact. However, for something like the code below you may like it:

for t=1:10
%  t
end

After removing comments, you can simply use the auto indentation feature again and the code will look proper again.

Upvotes: 1

Related Questions