Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains


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!

Comments below can no longer be edited.

56 Responses to Postfix Code Completion in IntelliJ IDEA 13.1 EAP

  1. Tomek says:

    March 4, 2014

    Such a nice feature. Like it very much!

  2. Hendrik says:

    March 4, 2014

    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!

    • Allen~m says:

      February 3, 2017

      Just hacking through myself but I think a use is “field [answer] entries”: of

      • Allen~m says:

        February 3, 2017

        Pardon . . I meant: PyCharm EDU as’ app/ interface

  3. Dave Hulbert says:

    March 4, 2014

    Will this be coming to PhpStorm?

  4. Vilis says:

    March 4, 2014

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

  5. Petr says:

    March 4, 2014

    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:

    March 4, 2014

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

    • Darren Bishop says:

      March 19, 2014

      +1, another feature that seems to be attached to a language unnecessarily

      • Oliver says:

        March 20, 2014


        • moks says:

          March 21, 2014


          • charles says:

            November 11, 2017

            well, it sucks that I can’t use it from Groovy , Java’s close cousin

  7. Tim says:

    March 4, 2014

    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:

      March 4, 2014

      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:

      March 4, 2014

      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:

      March 6, 2014

      “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:

      March 7, 2014

      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:

    March 4, 2014

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

    • Alexander Zolotov says:

      March 4, 2014

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

    • controlflow says:

      March 4, 2014

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

  9. Anthony Accioly says:

    March 6, 2014

    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. Dmytro Danylyk says:

    March 19, 2014

    Any way I can add my own Postfix Templates?

    • Andrey Cheptsov says:

      March 19, 2014

      Which one you’d like to add?

      • Denis Tulskiy says:

        March 20, 2014

        string format would be nice

        “%d – %d”.format would turn into
        String.format(“%d – %d”, )

      • Stefan says:

        March 21, 2014

        System.out.println() would be useful

        • Callum Macrae says:

          March 25, 2014

          That already exists (if live templates are enabled). Type “sout” and press tab.

      • Sean Patrick Floyd says:

        March 27, 2014

        Oh, many different ones. especially with Guava
        .optional -> wraps an expression in an Optional
        .or -> wraps with Objects.firstNonNull()
        .cnn -> wraps with Preconditions.checkNotNull()


      • Per Salomonsen says:

        April 2, 2014

        .tc -> try { expr } catch (…) {}
        .tf -> try { expr } finally {}
        .tcf -> try { expr } catch (…) {} finally {}

        ..comes to mind.

      • ben says:

        June 16, 2014

        It would be nice to have a template for Android debug logs:
        Log.d(TAG, “%STRING%”);

  11. Pavel Alexeev says:

    March 19, 2014

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

  12. Daniel Gornstein says:

    March 19, 2014

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

  13. Swen Thümmler says:

    March 20, 2014

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

    • norill says:

      August 9, 2018

      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:

    March 20, 2014

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

  15. Sethuraman says:

    March 20, 2014

    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:

    March 20, 2014

    Would be nice to add “new”:

    to resolve to

    new SomeClass(

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

    April 8, 2014

    […] Postfix code completion: […]

  18. Thierry Lévèque says:

    April 28, 2014

    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:

    May 7, 2014

    Is it possible to define custom postfix-completion templates?


    • Andrey Cheptsov says:

      May 21, 2014

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

      • Diane says:

        May 29, 2014

        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:

        August 17, 2014

        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:

    • Sergey Ignatov says:

      May 21, 2014

      Please watch/vote:

  20. Bruce says:

    May 17, 2014

    what’s the difference with live templates?

    • Andrey Cheptsov says:

      May 21, 2014

      regular live templates neither affect or depend on the code before the caret

  21. My Favourite IntelliJ IDEA Features | Voxxed says:

    December 12, 2014

    […] this awesome post in IntelliJ Blog for additional information about Postfix […]

  22. Damian says:

    March 17, 2015

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

  23. Kinz says:

    August 20, 2015

    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.

  24. Use Android Studio Like a Pro! - Intellectsoft Blog says:

    October 12, 2018

    […] Documentation on Postfix operations […]

Discover more