trimIndent
Detects a common minimal indent of all the input lines, removes it from every line and also removes the first and the last lines if they are blank (notice difference blank vs empty).
Note that blank lines do not affect the detected indent level.
In case if there are non-blank lines with no leading whitespace characters (no indent at all) then the common indent is 0, and therefore this function doesn't change the indentation.
Doesn't preserve the original line endings.
Since Kotlin
1.0See also
Samples
import java.util.Locale
import kotlin.test.*
fun main() {
//sampleStart
val withoutIndent =
"""
ABC
123
456
""".trimIndent()
println(withoutIndent) // ABC\n123\n456
//sampleEnd
}