Live Templates

Live templates provide snippets for common AsciiDoc patterns. They guide authors to structure their documents.

Basic Functionality

Once the user types ad, a list of templates appears. Continue typing characters to restrict the list of the template names. A Tab expands the current entry.

Users can add their own live templates to avoid repetitive typing and to ensure consistency. Go to File  Settings…​  Editor  Live Templates  AsciiDoc for this configuration.

Special template ad-tag-include

How the snippet tag include template works

All live templates of this plugin except one will only be available when editing AsciiDoc content.
One live template is special: ad-tag-include

This template adds comments with the tag-syntax to your source file that mark snippets to be extracted by AsciiDoc include preprocessor macros later. Read more in the Asciidoctor user manual in section Select Portions of a Document to Include.

Example showing how snippets work

Given the following text file…​

Text file with a marked snippet
Other text
// tag::tagname[]
Some Snippet
// end::tagname[]
more text

…​ and an AsciiDoc source like the following …​

AsciiDoc document that includes the snippet
Some text from another file:

include::text.txt[tag=tagname]

…​ this produces the following output:

Some text from another file:

Some Snippet

Using the tag include live template

This live template works in two ways:

Create an empty snippet

Type ad-tag-include when no text is selected.

This creates empty snippets with tag boundaries. The plugin places the cursor at the tag name. Once the user has changed the tag name and pressed Enter, the plugin places the cursor within the snippet, and the user can start typing the snippet’s text.

Create a snippet from existing text

Selecting a text block, then choose Surround with…​ (Shortcut Ctrl+Alt+T on Linux/Windows or ++T on macOS) and then choose ad-tag-include.

This creates the tag boundaries before and after the previously selected text. The plugin places the cursor at the tag name. Then the user types the tag name and presses Enter.

Disabling the tag include live template

If a user doesn’t want to see the ad-tag-include live template when typing content in any other language, there are two options to disable it:

Disable this live template completely
  1. Go to menu File  Settings…​  Editor  Live Templates  AsciiDoc  ad-tag-include.

  2. Uncheck the checkbox to disable this live template.

Choose specific languages for this live template
  1. Go to menu File  Settings…​  Editor  Live Templates  AsciiDoc.

  2. Select the entry ad-tag-include.

  3. Choose Change at the end of the line starting with Applicable in…​ (might need to make the dialog a little wider).

  4. Select the file types where the live template should appear.