简体   繁体   中英

How can I add a custom Kotlin postfix completion in IntelliJ IDEA / Android Studio?

It seems I can't add custom postfix completions for Kotlin in neither IntelliJ IDEA (2018.3), nor in Android studio (3.2.1). If I go to preferences | Editor | General | Postfix Completion and I click the add button, there is no option for Kotlin (see screenshots below). Is it possible to add new postfix completions?

I'd like to add a .with postfix completion, so that x.with would expand to

with(x) {
    // The caret should go here
}

Side note: I think it's a shame there is no postfix completion for with out of the box.

Screenshots of IntelliJ IDEA (2018.3) and Android Studio (3.2.1):

IntelliJ IDEA后缀完成设置 Android Studio后缀完成设置

I checked, and it's not possible in Android Studio nor IntelliJ. Probably the definition language doesn't have support for Kotlin yet.

However, what you could try, is try the following plugin: https://plugins.jetbrains.com/plugin/9862-custom-postfix-templates .

It seems to be well maintained, and has support for Scala, Kotlin, Groovy, etc. I haven't tried it myself, but based on the documentation, it seems to be what you're looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM