# Snippets and history

[Wiki](../README.md) / [Station](README.md)

Station remembers the queries you run, and keeps the ones you want to reuse as snippets in
named collections.

## Snippets

A snippet is a named query with an optional description, the database it runs on and its
parameters. Collections group snippets: one per project, report or team, say.

- **Save:** **+ Snippet** above the editor, or **Ctrl+Shift+S** (**⌘⇧S** on macOS). Pick a
  collection, or name a new one. The Snippets panel opens to show where it went.
- **New:** hover a collection and press **+**. A blank tab opens with the name ready to
  type; press Enter and write the query, then **Save** adds it to the collection.
  **Discard** closes the tab without adding anything.
- **Open:** click or double-click a snippet in the Snippets panel (**Ctrl+2**, **⌘2**). It
  opens with its database and parameters. If a tab already has it, that tab comes forward;
  a query you are writing keeps its tab, and the snippet opens in a new one.
- **Save changes back:** above the editor, **Save** or **Ctrl+S** (**⌘S**) writes the tab
  back to its snippet. **Save as…** makes a new snippet instead.
- **Rename:** click the snippet's name above the editor, press **F2** over it in the panel, or
  right-click › **Rename**. Enter keeps the new name; Esc puts the old one back.
- **Edit** the description or query: ✎ on the row, or right-click › **Edit…**.
- **Move:** drag it within its collection, or onto another collection's name to move it
  there. Right-click offers **Move up**, **Move down** and **Move to**.
- **Delete:** × on the row, or **Delete** above the editor; the tab keeps the query. The
  message in the corner offers **Undo** for a few seconds.

New snippets and collections go at the end of the list, and everything stays in the order
you arrange it.

## Collections

Click a collection's name to fold or unfold it. Hover it for **+** (a new snippet), ✎ (edit,
export or delete) and ×. To save the query you are writing into a collection, right-click it ›
**Save the current query here…**. Drag collections to reorder them, or use
right-click › **Move up** / **Move down**.

To share a collection, right-click › **Export…** and send the file. Your colleague brings it
in with **Import** at the top of the Snippets panel; an imported collection is added beside
theirs, never over it. Deleting a collection asks first, since its snippets go with it.

## History

Every query you run is recorded in the History panel (**Ctrl+3**, **⌘3**), newest first. A
query you run again moves to the top rather than appearing twice.

- Click an entry to load it into the current tab. Hover it to see the whole query, when it
  ran and on which database.
- ☆ makes it a favourite: favourites stay at the top and survive **Clear history** (× in the
  panel's heading).
- × on an entry removes it, with **Undo** in the corner.

## Filtering

The Snippets and History panels have a filter box at the top. Type a few words: snippets
match on their name, description or query, and a collection whose name matches shows all
of its snippets; history matches on the query or the database. × or Esc clears the filter.

## Related articles

[Write and run queries](queries.md) · [Keyboard and mouse](keyboard.md)
