Help › Write SQL
Fold parts of a query
Hide statements, subqueries, CASE expressions and comments behind one line, and unfold them again.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
In a long tab you can fold a part away so that only its first line shows. The SQL is still there: running, copying and saving include what is hidden.
Fold and unfold
| To | Press |
|---|---|
| Fold what the cursor is in | ⌥⌘[ on macOS or Ctrl+Shift+[ on Windows and Linux |
| Unfold it | ⌥⌘] on macOS or Ctrl+Shift+] on Windows and Linux |
| Fold or unfold it, whichever applies | ⌘K ⌘L on macOS or Ctrl+K Ctrl+L on Windows and Linux |
| Fold everything | ⌘K ⌘0 on macOS or Ctrl+K Ctrl+0 on Windows and Linux |
| Unfold everything | ⌘K ⌘J on macOS or Ctrl+K Ctrl+J on Windows and Linux |
The commands are in the View menu. Some of the shortcuts are two keys pressed one after the other.
With the mouse, move over the margin beside the line numbers: an arrow appears on every line that starts something foldable. Click it to fold. A folded line is tinted and ends in a small ⋯ mark; click the arrow or the mark to unfold.
Pressing Fold several times folds the innermost part around the cursor first, then the part around that.
What can be folded
A statement that spans several lines.
What is inside parentheses over several lines: a subquery, the body of a
WITHquery, a list of columns, a longINlist.A
CASE … END.A
BEGIN … ENDblock, andIF,LOOPandWHILEblocks.A
/* … */comment, and two or more--comment lines in a row.A region you mark yourself with comments:
-- region Monthly totals SELECT date_trunc('month', created_at) AS month, sum(total) AS total FROM orders GROUP BY 1; -- endregion
When the closing ) or END starts a line of its own, it stays visible
under the folded line.
Moving and editing around folds
- The up and down arrow keys step over a folded part as if it were one line.
- Anything that has to put the cursor inside a folded part unfolds it: finding a match there, undoing a change there.
- Editing above a fold moves it along. An edit that reaches into the hidden lines unfolds them.
Folds last while the tab is open. They are not saved with a saved query or a file, and not kept when Querlyn restarts.
Help for Querlyn 0.1.0. All help topics