Custom Postfix Templates

Compatible with: IntelliJ IDEA Android Studio
Dec 10, 2017
Documentation | Screencast | Predefined templates

This plugin allows you to define your own postfix templates for Java, JavaScript, and Kotlin. It comes with a set of predefined templates which can be edited and extended, e.g.:
  • string.toInt → Integer.parse(string)
  • longValue.toInt → ((int) longValue)
  • array.toList → Arrays.asList(array)

Download plugin

Recent change notes

Version 1.3.0
  • Added option to add class/library dependencies to templates rules. For instance "".val expands now to
    • val s = ""; if Lombok is available, or to
    • final String s = ""; if Lombok is not available.
  • Added 16 templates for IDEA developers to the predefined templates.
  • Fixed #43: Could not use $ in default values of template variables.

General usage instructions

Go to Tools → Custom Postfix Templates and write your own postfix templates for your code or just the predefined ones to simplify your life. For instance, write "array.toList" and see how it gets replaced by "Arrays.asList(array)". Other predefined but editable templates are: toByte, toChar, toInt, toLong, toFloat, toDouble ● toList, toSet, toMap ● sort, sortBy, minBy, maxBy, groupBy ● exists, forall ● reverse, concat ● Optional.forEach ● String.r