Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an Eclipse equivalent of Visual Studio snippets?

Is there an Eclipse equivalent of Visual Studio snippets, if so what is it?

like image 318
Brian Avatar asked Nov 27 '25 14:11

Brian


1 Answers

Yes, there are.

You can access the existing ones selecting the Window>Preferences dialog. Then you navigate to Java > Editor > Templates subtree.

There you can see the existing ones. The first column is both the name and the activation code. For example, the "main" template inserts a default main block at cursor position.

You can use it inside the editor by typing "main" and pressing "CTRL + space". Then a pop-up is displayed so you can choose what template you want.

In the aforementioned dialog you can both define new templates or edit the existing ones at your will.

One thing to consider is that the content assist (the CTRL+space key combination) will only bring the appropriate results if the cursor is inside the context indicated in the second column.

That is, the "while" template, for example, will only work if the cursor is inside a Java Statement, and so on.

like image 179
Filipe Fedalto Avatar answered Nov 29 '25 05:11

Filipe Fedalto



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!