truncateLines

fun String.truncateLines(maxLines: Int, ellipsis: String = "..."): String(source)

Truncates to maxLines lines, appending ellipsis on the last line if truncated. Example: "a\nb\nc\nd".truncateLines(2) → "a\nb..."