Editora 0.19.0 docs. You are reading an archived version, kept so links from that release keep working. Read the 0.21.0 docs →
Snippets & templates
Editora has two related ways to stop retyping boilerplate: snippets for inline expansions, and file templates for whole new files. Templates use a similar placeholder syntax to the VS Code / TextMate one snippets use, with named variables instead of numbered tab stops.
Snippets
Type a prefix and press Tab, or pick from the Snippet: Insert… list
(C-c i). Once expanded:
- Placeholders are pre-selected so you can overtype them.
- Tab / Shift-Tab cycle the fields, and mirrors update live.
- A choice field shows a dropdown.
$0is where the caret lands when you finish.
Bodies use the standard syntax: $1, ${1:default}, mirrors (a repeated
number), ${1|a,b|} choices, and variables like $TM_FILENAME, $CLIPBOARD,
the current selection, and date/time. Snippets ship for 23 languages, plus a
global set that applies to every file.
Your own snippets
User snippets live in your config folder under snippets/<language>.json (or
global.json), and override the bundled ones by prefix. Three commands manage
them:
- Snippet: Manage… opens Settings → Snippets, where you add, edit, and remove them without touching the JSON.
- Snippet: Edit User Snippets… opens the file for the current language.
- Snippet: Reload Snippets picks up changes without a restart.
The format is the VS Code snippet JSON, and the reader is lenient about
real-world files (an array prefix registers every trigger, and an unknown
scope field is ignored).
File templates
New File From Template (C-c C-n, also a toolbar button) scaffolds a file,
or a whole set of files, from a reusable template. A picker chooses the
template, then a small wizard prompts for any variables it declares that
Editora can’t fill in itself.
Templates use the same ${var} / ${var:default} / $0 syntax as snippets,
plus a ${cursor} marker for the final caret. Bundled templates cover a Java
class, a Java compact source file, an HTML page, an HTML bundle (multiple
files), a Markdown doc, a Python script, a Python project (multiple files), a
shell script, and a Zsh script.
These variables are filled in for you rather than asked for: ${author},
${projectName}, ${packageName}, ${fileName}, ${baseName},
${extension}, ${date}, ${year}, and ${time}.
The wizard has an optional Folder field (with a Browse button): leave it
blank to create an unsaved buffer (with tab stops live, so you fill the
placeholders before saving), or pick a folder to write the file or files to disk
(refusing to overwrite) and open the primary one. Invoking New From Template…
from a project folder’s right-click menu pre-fills that folder. The two flows are
also the template.new and template.newInFolder commands.
Your own templates
Drop template JSON files in your config folder under templates/; a user
template overrides a bundled one with the same id. The author name used by
${author} comes from Settings → Templates → Author (it defaults to your OS
user). Template: Reload Templates picks up changes, and Template:
Manage… opens Settings → Templates to add, edit, or remove templates.
Autocomplete overlap
Snippet prefixes also surface in autocomplete: accepting a snippet from the completion popup starts a full tab-stop session rather than inserting plain text.