title: How do I create custom instance templates in IntelliJ IDEA?
body: <p>Intellij supports 'instance templates' i.e. templates usable with expression followed by a period, such as <code>cast</code>, <code>new</code> etc. So <code>MyClass.new</code> expands to <code>new MyClass(I)</code> where <code>I</code> is the cursor.</p>
  
  <p>Now I want to create my own template, <code>expression.orElse</code> which expands to:</p>
  
  <pre class="lang-java prettyprint-override"><code>Optional.ofNullable(expression).orElse(I)
  </code></pre>
  
  <p>I tried looking for options in Editor > Live Templates, but couldn't find anything relevant. Is this not possible in IntelliJ IDEA, or am I missing something?</p>