Live templates
Imagine you are typing the same content again and again, it can be a specific markup element with a specific structure or attributes, or a repeating fragment, like an admonition block, for example, a warning.
Live templates can help you here. These are customizable fragments allowing you to type a few letters followed by a configurable expansion key (by default, it is Tab
) and insert a frequently used fragment into your document or surround the text in the editor with some construct.
In this tutorial, you will create and reuse the live template while working on a document.
Create a Live template
For example, in this tutorial, we will create a template for a Markdown code block with some custom attributes.
Create a template group
It is handy to group templates to navigate through them easier.
Go to
.Click + on the right of the panel and select Template group.
Type the group name. In our case, we called it Custom markdown. Click OK.
Create a template
Select the previously created group in the list and click +. Select Live Template.
Specify the abbreviation — it will be a shortcut to invoke the template. It can contain Latin letters, numbers, dots, and hyphens. For example,
md-code
. It should be unique within a group.(Optional) In the Description field, describe in which cases this template is intended to be used. For example,
a custom collapsible Markdown code block included from a repository.
In the Template text field, add the template content that will be inserted in the document later.
Put the
$LANG$
variable to specify the language for syntax highlighting in a block.Put the
$END$
variable to indicate the position of the cursor when the snippet is complete. In our case, this issrc
attribute where the user will specify the filename.```$LANG$ ``` {src="$END$" collapsible="true" default-state="collapsed"}Define the context where the template will be used — pick Writerside Markdown templates for Markdown.
Apply your changes.
From now on, you can use the Live template on the go.
Get to know other ways to create live templates.
In the example below, we used the $END$
variable. Get to know other variables in Live template variables section.
Use a Live Template
Place a cursor in the editor.
Type md-code
and press Tab.
Specify the programming language and press Tab again.
Specify the filename to include the code block from it. Now you can limit the include to specific lines or code constructs.
Writerside already has a bunch of built-in live templates for frequently used markup fragments, like tabs, tables, lists, procedures, and more. They work in both Markdown and semantic topics.
To check them and customize them for your cases, go to
.