SQL editor and autocomplete

A modeless editor with conventional (CUA) keys, and autocomplete from the system catalogs. The same widget, read-only, shows definitions and the statement text in the dashboard and the profiler.

Moving

Arrows, Ctrl+Left / Ctrl+Right (word), End, PgUp / PgDn, Ctrl+Home / Ctrl+End as usual. Home goes to the first non-blank character; pressed again, to column 1. The gutter's line numbers are those of LINE n: in an error.

Selecting

Shift with any movement key; Ctrl+A; mouse drag. Second keys for Ctrl+Shift+Home / Ctrl+Shift+End: Alt+Shift+Home / Alt+Shift+End. With a selection, F5 sends only the selected text and Tab indents its lines.

Editing

KeyAction
Ctrl+Backspace / Ctrl+DeleteDelete the word left / right.
Ctrl+YDelete the line (as in Midnight Commander — not redo), or every line the selection touches. The clipboard is not changed.
Tab / Shift+TabIndent / unindent the line or the selected lines.
Ctrl+ZUndo — every change made in the tab, including replace-all and inserted templates.
Ctrl+Shift+Z / Alt+Shift+ZRedo. Many terminals send Ctrl+Shift+Z as Ctrl+Z: use Alt+Shift+Z.

Indentation is a tab character, displayed 4 columns wide (editor.tab_width in settings.toml); it is sent and saved as a tab.

Copy and paste

Ctrl+C / Ctrl+X / Ctrl+V, also Ctrl+Insert / Shift+Delete / Shift+Insert.

MechanismAvailableUsed for
Internal bufferAlwaysCopy and paste inside pgtc.
System clipboardpgtc on the local machine (Windows, macOS, Linux with X11 or Wayland)Copy and paste with other programs.
OSC 52Over SSH, in terminals that implement it (Windows Terminal, iTerm2, kitty, WezTerm, Alacritty, …)Copy from a remote pgtc into the clipboard of the terminal's machine.

Find and replace

The Find dialog
Ctrl+F in the editor.

Syntax highlighting

Autocomplete

Autocomplete: columns after an alias
Columns after the alias of sales.customer.

Names are read from the catalogs through the query tab's own session. Available in connected query tabs and in the SQL boxes of developer template forms. It is a heuristic on the lexer, not a parser.

When the list opens

What the list offers

The context is the statement around the cursor (between two ;):

Before the cursorOffered
FROM, JOIN, UPDATE, INTO, TABLE, or a , in a FROM listSchemas, and the tables, views, materialized views and foreign tables visible on the search_path
schema.The relations, functions and types of that schema
alias. or table. of this statement's FROM / JOINThe columns of that relation
anything elseColumns of this statement's relations; visible relations and functions; keywords
Functions and keywords
After co in the select list.

Keys while the list is open

Where the names come from, and when they are read again

Limits

Output columns of a subquery or a WITH query are not resolved. Inside a function or DO body each statement is analysed on its own.