Live Editor formatting and indents

조회 수: 12 (최근 30일)
Pat Donaldson
Pat Donaldson 2019년 3월 29일
댓글: Lee 2023년 11월 2일
I've been ignoring the Live Editor for a while, because most of my programming is done using classes and functions rather than scripts. However, I ran across articles on Literate programming, and they convinced me that there was real value in programming as a document. Also, I struggle with documenting my code (get it working, and worry about documentation tomorrow...), and the Live Editor seemed like a good fix for that.
As a test project, I took one of my functions, converted it to a live function, converted all the comments to Text, and added additional documentation and formatting (bold headers, etc). On the whole, I like the result - however, I find that the interspersal of text with code blocks tends to obscure the indentation levels. There are clearly some steps which can be taken to make the indentation clearer. I've decided that it's good practice to end a live code block (between text areas) on the same indent level that you entered at.
I'm going to do a for loop
yadda;
yadda;
for idx = 1:5
dothis;
dothat;
insert explanation for next step
otherstuff;
end
doNextStep;
is confusing. Better to split it up like:
I'm going to do a for loop. discussion of all the stuff the for loop is going to do
yadda;
yadda;
for idx = 1:
dothis;
dothat;
%brief comment inserted inline
otherstuff;
end
finished with the for loop, explanation of all the next steps
doNextStep;
This is helpful, but I feel that the indent structure would be clearer if I could set the live editor text to indent paragraphs to the same level as the code. It looks like I can set the indent of the first line of a paragraph to match the code, but following lines revert to the left edge.

채택된 답변

Michael Abboud
Michael Abboud 2019년 4월 2일
Hi Pat, this is actually something that we have been considering -- adding support to indent rich text to match the indentation of nearby code. We think that this may help to better integrate code and text for certain workflows, and from your post -- it sounds like this is one of those workflows.
It's good to see that there is some desire for this functionality, and it's always great to get concrete examples of how it would be used. Thanks for sharing your thoughts!
  댓글 수: 2
Nicholas Kiratzis
Nicholas Kiratzis 2020년 8월 20일
편집: Nicholas Kiratzis 2020년 8월 20일
Any recent updates for this livescript functionality? I second Pat's use case.
Lee
Lee 2023년 11월 2일
I would also like this functionality.
I'm surprised I'm the only one who finds the live editor almost useless without it.

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

추가 답변 (1개)

Alexandra Ritger
Alexandra Ritger 2020년 5월 13일
Hi, I'm also wondering if text indentation is an option, or if the the for loop can have a bracket from start to finish like it does in the editor window?

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by