Postfix Code Completion in IntelliJ IDEA 13.1 EAP

A lot of people tend to think these days completion is a regular feature for every IDE. Well, that is not exactly the case. IntelliJ IDEA has already demonstrated that there is no such thing as a regular feature.

Take code completion, for example. IntelliJ IDEA never stops evolving in this area, and to prove it once more, today we are proud to introduce Postfix code completion, a new kind of completion which will hopefully extend your productivity even more.

Postfix code completion helps reduce backward caret jumps as you write code. It lets you transform an already typed expression to another one based on the postfix you added, the type of expression and its context. For example, the “.if” postfix applied to a boolean expression wraps it with an if statement. Likewise the “.notnull” triggers a surround template checking the expression for the null value.


Notice that the postfix completion suggestions are shown as part of the basic completion. In case you’d like to see the whole list of postfix completions applicable in the context, use the Ctrl + J shortcut (Cmd + J for OS X).


To see all the postfix templates and change their settings (for example, to disable the templates you don’t need), go to Settings → Editor → Postfix Templates.


Note that some of the templates have aliases (i.e. alternative postfix names). For instance, the exclamation mark will have the same effect as “.not”. Just enter “!” after an expression and press Tab to negate it. The IDE may ask you which expression you meant, if there is more than one.



Many thanks for the original idea and the initial implementation of this feature to our .NET colleagues.

As always, we welcome your feedback on our discussion forum and your bug reports in the issue tracker.

Develop with Pleasure!

This entry was posted in New Features and tagged , , . Bookmark the permalink.

56 Responses to Postfix Code Completion in IntelliJ IDEA 13.1 EAP

  1. Tomek says:

    Such a nice feature. Like it very much!

  2. Hendrik says:

    This is the kind of feature I always wanted but was never able to express it – great! I would love to see this in AppCode!

  3. Dave Hulbert says:

    Will this be coming to PhpStorm?

  4. Vilis says:

    It seems more like a feature for a programming language than IDE.

  5. Petr says:

    It looks really great.

    A quick note for those stuck with Eclipse: Use ‘Surround With’ (Alt+Shift+Z). You have to define your own templates if you want to be as productive as the examples here (there are only a few predefined), but the result is very similar.

  6. Konrad Machlowski says:

    It seems to me that it works only with Java.
    Is there a plan to enable this for AS3/Flex development env?

  7. Tim says:

    Thanks for reminding me why I’ll never use Java again.

    Only in a language as verbose, inflexible, and inconsistent as Java could such a feature exist.

    • controlflow says:

      Actually, this feature was designed first for the languages with ‘statements’ (a lot of imperative languages has separation of expression and statements).

      Statements are important part of the language, but because of the syntax, they are force you to think of exact kind of the statement you need (if/while/for/just expression) before writing next line of code. This plugin is designed to let you start with the expression, explore the apis with code completion, think about what you wanna do next and at the end of expression you can simply surround expression into statement kind you need, without backward caret jumps.

    • Jura Gorohovsky says:

      Tim, the feature was borrowed directly form ReSharper.Postfix, a plug-in to ReSharper (which is turn a plug-in to Visual Studio), and was originally written to support C#.

      Not sure if you have ever used C# but does your comment mean that you’ll never use it from now on?

    • Daniel says:

      “as Java could such a feature exist”
      It has lived without such a feature for 24 years so far. Objective C is totally worse than Java. I hope to see this feature in AppCode very soon.

    • Rob says:

      Central casting had to dispatch the usual Java’s too much trouble troll. Thanks for your contribution here.

      For my own part, I want to say this is FANTASTIC! Thanks!

  8. foobra says:

    what’s difference between this and postfix code completion plugin?

    • Alexander Zolotov says:

      Postfix code completion plugin had been merged into idea-community repo and won’t be supported separately.

    • controlflow says:

      Actually, it is postfix plugin itself. It became part of the product.
      Plugin is no longer in development.

  9. Not related to postfix code completion. But how have you managed to have IntelliJ auto-complete (or copy) the word registered after:

    new RuntimeException("Already r");?

  10. Any way I can add my own Postfix Templates?

  11. Pavel Alexeev says:

    It does not work to me on Linux. Is it require any settings? All templates enabled as I see.

  12. Daniel Gornstein says:

    Love it! Would love to see this for JS as well!!

  13. Swen Thümmler says:

    Will it be possible to modify the templates? I’d rathe have (null != object) over (object != null) in my code…

    • norill says:

      this idiom is largely obsolete. it’s purpose is to protect from accidental if(a = null), but there is no way compliator would let it through in java

  14. Benjamin Weiss says:

    Having the possibility to add my own postfix completion items just like Live Templates would be great.

  15. Sethuraman says:

    Adding your own Postfix templates would be of real help

    Every user would have his own templates to add. The one suggested already is .format.
    Another could be .int which would give Integer.parseInt(“”)

    Like that you could add as many as you want. It could be another group in live templates. Instead of creating surround with templates, postfix is easier and more intuitive.

  16. Mark says:

    Would be nice to add “new”:

    to resolve to

    new SomeClass(

  17. Pingback: Android Studio 0.5.0リリース | フリーソフト/無料ソフト startnews24

  18. Thierry Lévèque says:

    Yes, being able to modify or add template would be great!
    I would love to add thing like StringUtils.isBlank() or things like that…

  19. Benjamin W. says:

    Is it possible to define custom postfix-completion templates?


    • Andrey Cheptsov says:

      not yet, but we thinking of it. what kind of templates you would add once it’s possible?

      • Diane says:

        For me, it would be great to be able to change for example sout to sysout + Ctrl-space to match eclipse autocompletion shortcuts.

      • Aleksander.w1992 says:

        I’d like to spot that defining own live templates (those with “$SELECTION$) can partially replace defining own postfix templates. You just define your own template and press ctrl+alt+j instead of ctrl+j (crtl+alt+t is very similar).

        Maybe keeping keeping ctrl+j for default postfix templates and crtl+alt+j for user’s be a good idea as action is very similar?

        Personally I use on a regular basis StringUtils template:
        And StringUtils.isBlank as a little more hardcoded:

  20. Bruce says:

    what’s the difference with live templates?

  21. Pingback: IntelliJ postfix completion | Yair's Tweaks & Tricks

  22. Pingback: My Favourite IntelliJ IDEA Features | Voxxed

  23. Damian says:

    My loved feature ! but what about postfix completion for scala ?

  24. Kinz says:

    Very nice feature! I usually use the .for, .fori postfix and never wrote any for-loop now.

    But, we really really need a way to config custom postfix completion like live template.

  25. Pingback: Use Android Studio Like a Pro! - Intellectsoft Blog

Leave a Reply

Your email address will not be published. Required fields are marked *