is there an `IndentedStringBUilder` anywhere? I fe...
# general-advice
g
is there an
IndentedStringBUilder
anywhere? I feel like I've bumped into this need a couple times. I want a stringbuilder (or perhalps more simply an
Appendable
) that will auto-insert a prefix for each newline. something like
Copy code
val builder = StringBuilder()
builder.appendLine("preamble {"}

val indented = builder.indent(indent = " ", indentCount = 2) // new reference but mutates same buffer as 'builder'

val multilineOutcodeString = someUserObject.toString()
indented.appendLine(multilineOutcodeString)

builder.appendLine("}") 

print(builder.toString())
outputting
Copy code
preamble {
  SomeUserObjectThatOutputsManyLines:
  SomeUserObjectExtraLine
  line2
}