Kirill Vashilo
Kirill Vashilo

Reputation: 1619

How to edit template in Android Studio / JetBrains IntelliJ IDEA?

I wonder to add changed "loge" template in the Android Studio editor to remove the last required param - Exception object. How "loge" template result looks now:

Before the dafualt template insert:

public void doSmth() {
    //start write "loge" word here
}

After the dafualt template insert:

public void doSmth() {
    Log.e(TAG, "doSmth: ", );
}

Upvotes: 5

Views: 361

Answers (1)

Kirill Vashilo
Kirill Vashilo

Reputation: 1619

So to add template you have to follow several simple steps:

  1. Open "Settings -> Editor -> Live templates -> AndroidLog" Settings -> Editor -> Live templates -> AndroidLog
  2. Click the plus button, select "1. Live Template"
  3. Fill the fields like I did:
    • Abbreviation: le
    • Description: Log.e(TAG, String)
    • Template text: android.util.Log.e(TAG, "$METHOD_NAME$ failed: $content$"); Fill the fields
  4. Click "Edit varables", select "methodName()" for METHOD_NAME variable Edit varables dialog
  5. One more important thing! Define context to Java -> Statement: Define context to Java -> Statement
  6. Click "Apply", click "OK", Enjoy your own template! :)

Official documentation is here.


Your template in work: Your template in work enter image description here

public void doSmth() {
    Log.e(TAG, "doSmth failed: ");
}

Upvotes: 7

Related Questions