Does Matlab have the function to format script?

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.

 채택된 답변

Walter Roberson
Walter Roberson 2016년 6월 11일

2 개 추천

No, MATLAB does not have that. Fortunately, David Varga recently mentioned releasing a beautifier; see https://github.com/davidvarga/MBeautifier

추가 답변 (4개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 10일

14 개 추천

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

zzzhhh
zzzhhh 2016년 6월 11일
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.
thank you

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2022년 1월 8일

6 개 추천

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.
Julian Hapke
Julian Hapke 2023년 12월 11일

0 개 추천

Here's a MATLAB snippet that depends on the undocumented tree2str and mtree, but produces a reasonable result:
tree2str(mtree(FILENAME, '-file', '-comments'))

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2016년 6월 10일

답변:

2023년 12월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by