3

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

bdukes
  • 152,002
  • 23
  • 148
  • 175
Brian
  • 6,910
  • 8
  • 44
  • 82
  • 2
    Check here, see if this helps: http://stackoverflow.com/questions/237987/storing-code-snippets-in-eclipse – nighthawk454 Jun 18 '12 at 14:23
  • Can you describe the feature in a way that doesn't require someone to have had experience with Visual Studio to understand the question? – nitind Jun 18 '12 at 15:55

1 Answers1

2

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.

Filipe Fedalto
  • 2,540
  • 1
  • 18
  • 21