How to apply "smart indent" to a file programmatically

12 ビュー (過去 30 日間)
Joseph
Joseph 2011 年 7 月 12 日
編集済み: Oleg Komarov 2015 年 12 月 7 日
I have wrote a function that writes other functions. I want to now apply smart indent to the file to improve the aesthetics of the created function by aligning if_ends,etc. How can I do this programmaticly instead of the usual 'right-click' and select method as if programming manaually.

採用された回答

Oleg Komarov
Oleg Komarov 2011 年 7 月 12 日
編集済み: Oleg Komarov 2015 年 12 月 7 日
Suppose you have this fcn saved as foo:
function l = foo()
for l = 1:10
l
for l
l = 1:10
end
end
Then using editor API:
h = matlab.desktop.editor.openDocument('C:\Users\Oleg\Desktop\foo.m');
h.smartIndentContents
h.save
h.close

その他の回答 (1 件)

Jason Ross
Jason Ross 2011 年 7 月 12 日

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by