Drafts includes an extensible system to provide drop-down autocomplete suggestions while typing in the editor. Autocomplete includes a global system for creating and inserting text snippets, as well as additional autocomplete suggestions provide by syntax definitions
Global autocomplete is enabled on the “Autocomplete” tab on the Editor Preferences window, access via the
Aa button at the lower right of the editor, or via
Drafts > Editor Preferences... in the main menu.
To use global autocomplete, configure the following values:
- Enable Autocomplete
- Set a Trigger: The trigger text should be a short, unique text string. When the trigger text is typed in the editor, it will trigger the autocomplete suggestion drop-down to appear. It is recommend this trigger be at least 2 characters. The trigger text itself will be removed when selecting an item from the drop-down. It is recommended you avoid using
<<as triggers as they conflict with other autocomplete definitions in syntax files (see below).
- Process Template Tags: Enable if you intend to use Drafts template tags in items.
- Setup Autocomplete Items: Create one or more items to appear as suggestions in the drop-down. Each item has two fields:
- Name: A short, easy to identify label for the item. This value will appear in the drop-down, and will be used to filter the list in the drop-down as you keep typing.
- Value: The text to be inserted if the item is selected. This can be same as the label, but in many cases will contain additional text. Values can also contain Drafts template tags (details below).
If the “Process Template Tags” option is enabled, autocomplete item names and values will be passed through the Drafts template engine before use. This allow dynamic insertion of values such as dates/times, location information, and more. For details on available tags, see the Templates article.
The built-in Markdown syntaxes provide two additional default autocomplete suggestion triggers:
[[: Allow selection of draft titles to ease creation of
[[wiki-style]]cross-links to other drafts
- Draft insertion:
<<: Allows selection and insertion of the full text of other drafts at the cursor position.
Custom syntax definitions may include additional autocomplete definitions. Consult documentation for any installed custom syntaxes for capabilities they may provide.