Help › Write SQL

Use Vim keys

Turn on Vim mode in the SQL editor, and see which Vim commands work, which Querlyn shortcuts keep working, and what is not supported.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

Vim mode gives the SQL editor Vim's normal, insert and visual modes. It is off unless you turn it on, and it applies to the SQL editor only, not to the results or to dialogs.

Turn Vim mode on

Choose Edit › Toggle Vim Mode, or open Settings and turn on Vim mode under Editor. The same command turns it off.

The status bar shows the mode as Vim does: NORMAL, -- INSERT --, -- VISUAL --, with the keys of a command you are in the middle of. The cursor is a block in normal and visual mode, a bar in insert mode, and an underline while a command waits for its motion.

What keeps working

Querlyn's own shortcuts work in every mode: running a statement (⌘↩ on macOS or Ctrl+Enter on Windows and Linux), saving (⌘S on macOS or Ctrl+S on Windows and Linux), the command palette, formatting, folding and the rest. In insert mode, suggestions, snippets and several cursors behave as they do without Vim.

⎋ on macOS or Esc on Windows and Linux leaves insert mode. If the list of suggestions is open, the same press closes it too.

Vim mode is the SQL editor's. The WHERE and ORDER BY fields of a table tab, the find bar and the other text fields type as ordinary text fields.

Commands that are supported

KindKeys
Movingh j k l, w b e and W B E, 0 ^ $, gg G, f F t T with ; and ,, %, { }, + -
ScrollingCtrl-d Ctrl-u Ctrl-f Ctrl-b
Entering insert modei a I A o O, s S, c with a motion, C
Changingd c y > < with a motion or a text object, doubled for a line (dd, yy, >>); x X D Y; r; J and gJ; ~; p P
Text objectsiw aw, iW aW, quotes (i' a' i" a"), brackets (i( a(, i[, i{, i<, also ib and iB)
CountsA number before a command or a motion: 3dd, d2w
Undo and repeatu, Ctrl-r, .
Visual modesv (characters), V (lines), Ctrl-v (block), with o to move to the other end; d c y > < ~ u U r J p; I and A on a block
Registers"a to "z, "A to "Z to append, "0, "1 to "9, "-, "_, and "+ or "* for the system clipboard
Searching/ and ?, n N, * #
Command line:w, :q, :q!, :wq, :x, :noh, a line number such as :42, and :s

Each command is one step for u, including everything typed in one visit to insert mode.

How some of them behave here

  • The unnamed register is not the clipboard, as in Vim. yy and p use Vim's register; ⌘C on macOS or Ctrl+C on Windows and Linux and ⌘V on macOS or Ctrl+V on Windows and Linux use the clipboard in every mode. To reach the clipboard from Vim commands, use "+.
  • Searches ignore case unless the pattern has a capital letter, and use the same regular expressions as the find bar, plus Vim's \< and \> for word boundaries. Matches stay highlighted until :noh.
  • :w saves the tab as ⌘S on macOS or Ctrl+S on Windows and Linux does, asking for a name when the tab is new. :q closes the tab, and asks first if it has unsaved changes.
  • :s replaces on the current line, on a range (%, '<,'>, line numbers, ., $), with the flags g, i and I. In the replacement, & is the match and \1 to \9 are groups.
  • The mouse works: a click puts the cursor on a character, and a drag starts visual mode with that selection.
  • Folded parts count as one line for j and k, and dd on a folded line takes the whole folded part.

Messages from Vim commands, such as "E486: Pattern not found", and the command line itself appear in a bar under the editor.

What is not supported

Macros (q), marks other than '< and '>, gv, H M L, zz and the z fold keys, replace mode (R), Ctrl-o in insert mode, :set, and a .vimrc file. Vim's keys cannot be remapped.

Help for Querlyn 0.1.0. All help topics