Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 postfix completion settings Android Studio postfix completion settings

like image 797
Erik Avatar asked Dec 18 '18 09:12

Erik


1 Answers

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.

like image 191
Erik Pragt Avatar answered Sep 22 '22 05:09

Erik Pragt