How to apply "smart indent" to a file programmatically
12 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
h = matlab.desktop.editor.openDocument('C:\Users\Oleg\Desktop\foo.m');
h.smartIndentContents
h.save
h.close
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!