Friday, August 30, 2019

A better way to display nested code blocks

Admittedly this takes alot of lines (13 lines):

i=0;while(i<x)
{
j=0;while(j<y)
{
k=0;while(k<z)
{
//code here
k+=1;
}
j+=1;
}
i+=1
}

However, it is much easier to read than the 'industry standard' method of putting opening braces at the end of lines (10 lines):

i=0;while(i<x) {
j=0;while(j<y) {
k=0;while(k<z) {
//code here
k+=1;
}
j+=1;
}
i+=1
}

What would be nice is to write it either way you want, but when the cursor isn't nearby, display it like this (7 lines):

i=0;while(i<x)
j=0;while(j<y)
k=0;while(k<z)
//code here
k+=1;
j+=1;
i+=1

Easy to read AND doesn't take alot of lines!

\u259B = ▛
\u2599 = ▙

UPDATE:

Better yet, don't just display it that way when the cursor isn't nearby, but also write it this way.
▛ indicates exactly where the code block begins
 ▙ indicates that the code block ends at the next carriage return encountered



No comments:

Post a Comment