Help › Write SQL
Insert snippets
Insert a ready-made piece of SQL by typing a short word, fill in its fields with Tab, and make, import and export snippets of your own.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
A snippet is a piece of SQL you insert by typing a short word. Querlyn comes with a few, and you can add your own.
Insert a snippet
- Type the snippet's word, for example
sel. It appears in the list of suggestions with the tagsnip. - Take it with ↩ on macOS or Enter on Windows and Linux or ⇥ on macOS or Tab on Windows and Linux.
- The snippet is inserted with its first field selected. Type to replace the field.
- Press ⇥ on macOS or Tab on Windows and Linux to go to the next field, ⇧ on macOS or Shift on Windows and Linux and ⇥ on macOS or Tab on Windows and Linux to go back, and ⎋ on macOS or Esc on Windows and Linux when you are done.
While a snippet's fields are being filled in, the status bar says which one you are in, such as "Snippet field 1 of 3", and then the keys that go to the next field, go back and end the filling, as they are set on your computer. A field that appears in several places changes everywhere as you type. Filling ends at the last field, with ⎋ on macOS or Esc on Windows and Linux, or when you press ⇥ on macOS or Tab on Windows and Linux with the cursor outside the snippet.
When a keyword and a snippet have the same letters, the keyword comes first in the list.
The snippets that come with Querlyn
| Word | Inserts | Offered |
|---|---|---|
sel | SELECT … FROM … WHERE … | At the start of a statement |
ins | INSERT INTO … VALUES … | At the start of a statement |
upd | UPDATE … SET … WHERE … | At the start of a statement |
cte | WITH … AS (…) SELECT … | At the start of a statement |
txn | The statements that start and commit a transaction in your database, with the cursor between them | At the start of a statement |
join | JOIN … ON … | After a table |
case | CASE WHEN … THEN … ELSE … END | Inside an expression |
Make a snippet of your own
Open Settings (⌘, on macOS or Ctrl+, on Windows and Linux) and go to Snippets, or use . The buttons there are New Snippet…, Edit…, Delete…, Import… and Export…. In the command palette they are , , , and . Your snippets are listed first, the built-in ones under them.
Choose New Snippet…. To start from SQL you already wrote, select it in the editor and choose instead.
Fill in the dialog:
Field What to enter Name What the snippet is. It is shown beside the prefix in the list of suggestions. Prefix The word you type to get it: letters, digits and _, not starting with a digit, at most 40 characters.Description Optional. A note about the snippet. Dialect Every dialect, or one database's dialect. The same prefix can be used once per dialect. Body The text to insert, with fields; see below. Choose Save.
A snippet of yours with the prefix of a built-in one replaces the built-in one.
Write a snippet's body
| Write | Meaning |
|---|---|
$1, $2 | A field. ⇥ on macOS or Tab on Windows and Linux visits fields in number order. |
${1:table_name} | A field that starts with the text table_name, selected so that typing replaces it. |
| The same number twice | One field shown in two places: what you type in one appears in the other. |
$0 | Where the cursor ends up after the last field. |
\$, \}, \\ | A real $, } or \. |
For example, this body:
SELECT count(*) FROM ${1:table} WHERE ${2:condition};$0
A snippet of several lines takes the indentation of the line it is inserted on.
Note: To put a PostgreSQL parameter such as $1 in a snippet, write
\$1. Save Selection as Snippet… does this for you.
Move snippets between computers
Export… writes all your snippets to one JSON file. Import… reads such a file: a snippet with the same prefix and dialect as one you have replaces it, the others are added, and entries that are not valid are skipped and counted in the message. A file may hold at most 1,000 snippets and 4 MB.
With sync turned on, your snippets are kept the same on your computers without files; see Sync your computers.
Help for Querlyn 0.1.0. All help topics