News Ticker

IntelliJ Live Template

IntelliJ IDEA’s Live Templates are snippets of code that auto-complete at a touch of a key combination increasing your productivity.

Intellij IDEA is the best IDE I have ever used and one reason this is true is live templates.

Live templates are snippets of code that auto-complete at a touch of a key combination saving you valuable figure energy.

And this is how you create Live Template of your own.

Let’s create a live template that surrounds a variable with Objects.requireNonNull().

  1. Press CTRL + ALT + S to display the Settings dialogue box
  2. Click the + button and select Live Template
  3. Enter and abbreviation. Let’s enter orn
  4. Enter a description. Let’s enter Objects.requireNonNull(…)
  5. Enter the template text. Let’s enter
    java.util.Objects.requireNonNull($SELECTION$)$END$
  6. Ticket Shorten FQ names
  7. Click the Define link and select Java
  8. Let’s use it. Highlight a variable and press CRTL + ATL + J and select the live template we just created.
  9. That’s it.

Go make more live templates. Be careful it’s addictive.

Link to IntelliJ Live Template help.

Leave a Reply

%d bloggers like this: