The basic idea is to prevent caret jumps backward while typing code, let you start with the some expression, explore some APIs, think about what you are going to do and after finish with statement of some type.
See more examples.
This plugin became a core part of IntelliJ IDEA 13.1 experience! Source code is no longer maintained here.
Latest builds for IDEA 13 is available for download in IntelliJ IDEA plugin repository. To install into IDEA simply go Preferences – Plugins – Browse repositories... and search for "postfix".
Available templates:
.if
– checks boolean expression to be trueif (expr)
.else
– checks boolean expression to be falseif (!expr)
.var
– initialize new variable with expressionT name = expr;
.null
– checks nullable expression to be nullif (expr == null)
.notnull
– checks expression to be non-nullif (expr != null)
.instanceof
– checks typeexpr instanceof T ? ((T) expr).m : null
.not
– negates value of inner boolean expression!expr
.for
– iterates over collectionfor (T item : collection)
.while
– uses expression as loop conditionwhile (expr)
.arg
– helps surround argument with invocationmethod(expr)
.cast
– surrounds expression with cast(SomeType) expr
.new
– produces instantiation expression for typenew T()
.fori
– surrounds with loopfor (int i = 0; i < expr.length; i++)
.forr
– reverse loopfor (int i = expr.length - 1; i >= 0; i--)
.field
– introduces field for expression_field = expr;
.par
– surrounds outer expression with parentheses(expr)
.return
– returns value from containing methodreturn expr;
.switch
– switch over integral/enum/string valuesswitch (expr)
.throw
– throws exception of 'Throwable' typethrow new Exception();
.assert
- creates assertion from boolean expressionassert expr;
.synchronized
– produces synchronized blocksynchronized (expr)
Other features:
- Template expansion by
Tab
key in editor (like live templates) - Settings page to disable/enable particular postfix templates