M-file code formatting tool
34 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is there any similar to AStyle formatting tool for C/C++/C# languages which can beautify matlab m-file code?
Ctrl+I is too simple for my needs
2 comentarios
Jan
el 22 de Oct. de 2011
To answer this, we have to know your needs.
Personally I prefer an indentation, which is as trivial as possible - simply eye-popping.
Yuriy Chesnokov
el 22 de Oct. de 2011
Editada: Guillaume
el 28 de Nov. de 2018
Respuestas (7)
David Varga
el 6 de Jun. de 2016
I know it is an old question, and I just put this here as an addition.
I have just created it for personal use, it is a lightweight M-Script based tool that can be usable to format Matlab M-Code directly in the Matlab editor
5 comentarios
Ruben Lange
el 28 de Abr. de 2020
Hi David,
I know I am very late to this, but I don't really know how to add the root directory to my matlab path as you describe on the github page...
I also don't understand how to do the shortcuts part.
Could you (or someone else) help me with this?
Thanks in advance!
Ruben
Troy_Daniel
el 21 de Nov. de 2019
I know this question is quite old, and there is already a solution for Maltab GUI Editor. However, I prefer to edit M-files with vim, I'm frustrated to find that there was no a proper solution for commandline usage. So I imlement one using C++, which achieve quite simple formatting. The code is available on Github https://github.com/TroyDanielFZ/Matlab-M-Source-Formator .
This answer is posted in case that someone else need this implement for editors like vim.
0 comentarios
Brian Harris
el 23 de Ag. de 2022
Editada: Brian Harris
el 23 de Ag. de 2022
vscode has a pretty good matlab formater built in (formats on save). Underpinning the vscode plugin is a python script which you can run on the command line (matlab_formatter.py <matlab_file_name>)
0 comentarios
Narendra Kulkarni
el 29 de Sept. de 2014
Hi, I am facing the same problem. There arent any good tools to beautify matlab code or are there?
2 comentarios
Image Analyst
el 30 de Sept. de 2014
Editada: Image Analyst
el 30 de Sept. de 2014
I don't understand why control-I is not acceptable for you and Yuriy. What's wrong with the way it does it? It fixes the indenting, though it doesn't add spaces around operators such as = and +. Is that the problem?
Evgeny Mirkes
el 11 de En. de 2018
Editada: Evgeny Mirkes
el 11 de En. de 2018
Because indentation is not enough for beauty code.
Julian Hapke
el 11 de Dic. de 2023
Here's a MATLAB snippet that depends on the undocumented tree2str and mtree, but produces a reasonable result:
tree2str(mtree(FILENAME, '-file', '-comments'))
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!