Custom Postfix Templates

Compatible with: IntelliJ IDEA Android Studio
Jan 21, 2018
2 228
Documentation | Screencast | Predefined templates

This plugin allows you to define your own postfix templates for Java, Scala, Kotlin, and JavaScript. It comes with a set of predefined templates which can be edited and extended, e.g.:
  • string.toInt → Integer.parse(string)
  • array.toList → Arrays.asList(array)
  • file.lines → Files.readAllLines(file.toPath(), Charset.forName("UTF-8"))
  • file.getName().val → final String name = file.getName();

Download plugin

Recent change notes

Version 1.6.0
  • Improved settings dialog: Added option to select one of the supported languages and to reset/merge your templates with the predefined ones.
  • Added more Java and Scala templates.
  • Restructured tools menu:
    • Removed language specific menu items like "Open Java Templates".
    • Added menu item "Open Settings / Upgrade Templates".

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