Eclipse snippets / templates

Eclipse snippets / templates

The VS Code snippet is useful, so I searched Eclipse for a similar feature. We found "snippets" and "templates" as similar features. Let's compare each while explaining the outline.


It is a function to insert the code recorded in advance at the cursor position as it is.

How to add to snippets

  1. After selecting the range you want to snippet, right click => select Add to Snippet
  2. The category selection dialog opens. Select or enter a category. It is a selection field that seems to be impossible to enter at first glance, but you can enter it.
  3. The palette customization screen opens, where you can define the snippet name and variables. (The name changes here for some reason)

How to call a snippet

  1. Open the snippet view. If not, go to Window> View View> Other
  2. A list of registered snippets will be displayed. Click it.
  3. If there is a variable, the dialog for entering the variable will be displayed. Enter it.


Easy to register

It is easy to set by dragging + right-clicking the written code without calling the setting screen each time. I think it's easy to get to because there are no complicated settings such as context.


Can't be completed with just the keyboard

Since there are a lot of upper dialogs where shortcut keys are not set, There are many operations with the mouse. Those who want to use the keyboard as much as possible may be frustrated.


It is a function to add a unique template to the code assist called by Ctrl⁺Space. The variable definition is a type that focuses on that part and can be moved with tabs It behaves like a VsCode snippet.

How to add to snippets

  1. Open the template (java). You can reach it with Window> Settings> Java> Editor> Templates, but it is faster to open Quick Access with Ctrl + 3 and type Template. As an aside, you can also hit the snippet and quick access.
  2. You can change the existing one with the add or edit button from the new button. Apply it properly and then close it.
  3. Regarding variables, various built-in variables are available. Reference


Calling is easy anyway. Since it can be called in the same way as normal chord assist, you can use it comfortably with just the keyboard.


As mentioned above, the setting is troublesome. In the first place, the setting part is quite deep, Handling contexts and variables is complicated, so it takes time to get used to it.


Recommended Posts

Eclipse snippets / templates
Eclipse error
Eclipse --Springboot