Using Live Templates to type less

A simple approach to install the live templates is to copy its XML code and paste them into the IDE:

  1. Right click on OPENRNDR.xml → Open In New Window
  2. On the new window, select all the <template> ... </template> blocks (in other words, copy everything except the first and the last lines).
  3. Right click on the selected text → Copy
  4. In IntelliJ Idea, go to File → Settings → Editor → Live Templates
  5. Click on + on the right side of the window to create a Template Group called OPENRNDR.
  6. Click on OPENRNDR to select it.
  7. Press CTRL+V or Command+V to paste the copied XML templates into the OPENRNDR group.

Now you can use the live templates.

The cool thing about this copy-paste approach is that it makes it easy to share templates on a chat or post them here in the forum. For example here goes one I often use: dbc for drawer.bounds.center:

<template name="dbc" value="drawer.bounds.center" description="drawer.bounds.center" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="KOTLIN" value="true" />
  </context>
</template>
2 Likes