Reputation: 39
I was wondering if it is possible to create code templates with IntelliJ. I would like to save my getInstance() method into a variable, or something along those lines, and while I'm coding, can use the variable to generate my getInstance() method. Is this possible? If so how?
Thanks again, Niknea.
Upvotes: 3
Views: 1893
Reputation: 53525
You already have it (at least in the new versions of IntelliJ): use the shortcut: geti
(and press tab). Tested successfully on IntelliJ 13.0.3
ottrob pointed where it's defined: under "Live Templates" click the "Other" section and when it's expended you should see it defined as the first item.
Upvotes: 1
Reputation: 622
There are live templates which you can create.
Settings->Live Templates
There are lots of existing live templates already. Just add a new one.
For ex.: 'iter' is a already defined live template. When you code you just can type 'iter' (without quotes) and then press the tab button. This will produce a for loop.
Upvotes: 3