Does Matlab have the function to format script?

168 vues (au cours des 30 derniers jours)
zzzhhh
zzzhhh le 10 Juin 2016
Just wondering if Matlab has the function to format script, e.g., automatically add a space after a comma, or add spaces before and after an "=" when I press semicolon at the end of a statement, or select a block of script to be formatted and press some button. Thanks.

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Juin 2016
No, MATLAB does not have that. Fortunately, David Varga recently mentioned releasing a beautifier; see https://github.com/davidvarga/MBeautifier
  1 commentaire
Rayane Meghezi
Rayane Meghezi le 11 Août 2022
Thank you, seems to work well :D

Connectez-vous pour commenter.

Plus de réponses (4)

Azzi Abdelmalek
Azzi Abdelmalek le 10 Juin 2016
Select your code, then right click with your mouse, you will see all possibilities you have. For example (ctrl+i) which is smart indent
  2 commentaires
zzzhhh
zzzhhh le 11 Juin 2016
I didn't find any item in the context menu except smart indent that is related to code formatting as I mentioned in the question. Note that in my question the "format" does not refer to change of fonts, but more to proper addition of spaces and alignments.
Yash Mavare
Yash Mavare le 8 Jan 2022
thank you

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 8 Jan 2022
Type
control-a, to select all text in your editor window, then
control-i, to fix (properly align) the indenting of your lines of code.
  1 commentaire
oren montgomery
oren montgomery le 28 Août 2022
Modifié(e) : Walter Roberson le 28 Août 2022
Its smiliar to ctrl+i but as a few more functions

Connectez-vous pour commenter.


Florian Schanda
Florian Schanda le 13 Avr 2021
Modifié(e) : Walter Roberson le 13 Avr 2021
You might want to have a look at https://github.com/florianschanda/miss_hit

Julian Hapke
Julian Hapke le 11 Déc 2023
Here's a MATLAB snippet that depends on the undocumented tree2str and mtree, but produces a reasonable result:
tree2str(mtree(FILENAME, '-file', '-comments'))

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by