Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse count.fori code template / postfix completion similar to IntelliJ

IntelliJ has a feature called Postfix Completion. Is this available in Eclipse?

For example, in IntelliJ when you have

int count = 10;

count.fori

it becomes

int count = 10;

for (int i = 0; i < count; i++) {

}

I use both IDEs but i prefer Eclipse for its views but IntelliJ has some interesting code completions and templates that make life easier.

like image 665
Charles Bentley Avatar asked Oct 19 '25 13:10

Charles Bentley


1 Answers

Yes, postfix completion was introduced in Eclipse 4.14 (December 2019).

It works similarly to IntelliJ. For your example, if you type

    int count = 10;
    count.

and invoke autocomplete ("content assist", Ctrl-Space), Eclipse will offer the completion "foriub", which will yield the same loop as in IntelliJ. There's also "forllb", which will yield a loop counting backwards.

Notes:

  • For content assist to work, the cursor must be behind the dot. Also, the dot is required to invoke the postfix completion.
  • Postfix completion must be enabled in the Eclipse preferences (should be enabled by default). To check, got to Window / Preferences / Java / Editor / Content Assist / Advanced. There, the category "Java Postfix Template Proposals" must be enabled.
like image 52
sleske Avatar answered Oct 21 '25 15:10

sleske



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!