vxh.viet
11/15/2017 - 6:27 AM

kotlinMultilineFolding

Source: JetBrains

Question: How can I fold a multiline Kotlin function with expression body in Android Studio or IntelliJ IDEA?

Answer: The folding is only available for regular function, for multiline function with an expression body such as:

fun fizzBuzz(i: Int) =
        when {
            i % 15 == 0 -> "FizzBuzz "
            i % 3 == 0 -> "Fizz "
            i % 5 == 0 -> "Buzz "
            else -> "$i "
        }

Select the whole function or a region that you want to fold -> Ctrl+Alt+T (Surround With..) -> choose either “<editor-fold..>” or “region..endregion”