Skip to content

Snippets with tab stops and placeholders in the SQL editor #3612

Closed

Description

@datlechin

Problem

The only template in the editor is a saved query with a keyword. Accepting the keyword replaces it with the query's SQL, and a ;; in that SQL marks where the cursor lands; only the first ;; counts (features/favorites.mdx:82-92, apple/Packages/TableProMacCore/Sources/TableProAutocomplete/SQLSnippetMarker.swift).

  • There is one cursor position and no fields. A template for UPDATE <table> SET <column> = <value> WHERE <key> = <id> leaves the user to find and select each part by hand.
  • No default text to type over, and no way to fill the same name in two places at once.
  • Saved queries imported from other apps keep placeholders such as ${1:name} as literal text (features/connection-sharing.mdx:116).
  • Driver statement completions insert fixed text: SAP HANA's EXPLAIN PLAN entry inserts "SCHEMA"."TABLE" for the user to retype (apple/Plugins/HanaDriverPlugin/HanaMetadata.swift:43).

Proposed solution

  • Tab stops in a saved query's SQL: ${1:default} is a field with default text, ${1} an empty field, ${0} the final cursor, and the same number twice is one field mirrored as you type. A bare $1, $$ or $tag$ stays literal, so PostgreSQL parameters and dollar quoting are not touched.
  • After expansion, Tab and Shift+Tab move between fields, the current field's text is selected, and Escape or a click outside ends the session.
  • A choice field, ${1|ASC,DESC|}, opens a small menu at the field.
  • ;; keeps working and means the same as ${0}.
  • Placeholders in imported saved queries become live fields.
  • A starter set of snippets per dialect (INSERT ... ON CONFLICT DO UPDATE, CREATE INDEX, a CTE skeleton, ALTER TABLE ... ADD COLUMN), offered in completion with their own icon, editable, and removable.

Done when: a saved query with three numbered fields expands, Tab visits each in order, a mirrored field follows as you type, $1 in a PostgreSQL query stays literal, and ;; still works.

Alternatives considered

Save the template as a favorite with one ;; and edit the rest by hand after inserting it.

Platform

macOS

Related database type

N/A / General

Activity

  1. added
    enhancement
    platform-macos
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementplatform-macos

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions