StringIndentation extension

Extension methods for easier indentation of strings while preserving relative indentation.

on

Methods

getIndentationLevel() int

Available on String, provided by the StringIndentation extension

Returns the indentation level of this string.
indent(int indentationLevel) String

Available on String, provided by the StringIndentation extension

Returns this string with indentationLevel applied while preserving relative indentation.
indentBy(int howMuch) String

Available on String, provided by the StringIndentation extension

Returns this string with indentation level changed by howMuch.
trimMargin([String marginPrefix = '|']) String

Available on String, provided by the StringIndentation extension

Returns this string, but trims leading whitespace characters followed by the given marginPrefix from each line.
unindent() String

Available on String, provided by the StringIndentation extension

Returns this string with all extra indentation stripped while preserving the relative indentation.