title: How to create a kotlin live template for newInstance Fragments using Android studio
body: <p>I'm searching for a way to create a new Kotlin live code template so that whenever I type newIns.... it and hit tab it will be able to print the following as a live template choice:</p>
  
  <pre><code>companion object {
      fun newInstance(b: Bundle): DetailsFragment {
          val frag = DetailsFragment()
          frag.arguments = b
          return frag
      }
  }
  </code></pre>
  
  <p>In Java, it was done the same way and there is already a "newInstance" abbreviation and a live template exists in Android Studio. I want the same thing for Kotlin. Let me show you a photo :</p>
  
  <p><a href="https://i.stack.imgur.com/VYYOE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VYYOE.png" alt="enter image description here"></a></p>
  
  <p>Notice that, Java Android already has <code>newInstance</code> template. I want this for Kotlin. Here is what I have so far:</p>
  
  <p><a href="https://i.stack.imgur.com/TPVha.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TPVha.png" alt="enter image description here"></a></p>
  
  <p>and the template code I have so far looks like this:</p>
  
  <pre><code>companion object { 
      fun newInstance($args$:Bundle):$fragment$ {
          $nullChecks$
          android.os.Bundle args = Bundle();
          $addArgs$
          $fragment$ fragment = $fragment$();
          fragment.setArguments(args);
          return fragment;
      }
  }
  </code></pre>
  
  <p>but when I exit the settings and in Kotlin type the first few words of the abbreviation and hit tab or ctrl + spacebar on mac nothing happens. I guess I have the syntax wrong, I'm not sure. Anyone of suggestions?</p>