Key bindings and vim mode
The TUI's keys work out of the box, and you can change any of the app-wide ones. You can also edit SQL with vim keys.
To see every key in quarry itself, press F1 and type to filter, for example run, ctrl or vim. Each rebindable action shows its name on the right. That name is what you write in the config.
Change a key
Add a [keys] table to ~/.config/quarry/config.toml (run quarry --default-config to see a commented example). Each line names an action and gives it one key or a list of keys:
[keys]
run_statement = ["ctrl+enter", "ctrl+e"] # several keys
run_all = "f9" # one key
themes = "alt+t"
quit = [] # no key (Quit stays in the command palette)A line replaces all of that action's default keys. Actions you don't list keep their defaults.
How to write a key
Modifiers, then the key, joined with +. Case doesn't matter.
| Write | For |
|---|---|
ctrl, alt, shift | Modifiers, e.g. ctrl+shift+enter |
a … z, 0 … 9, ?, /, … | A character |
enter, esc, tab, space, backspace, delete, insert | Named keys |
up, down, left, right, home, end, pageup, pagedown | Movement keys |
f1 … f24 | Function keys |
When keys collide
quarry sorts collisions out for you, so a new binding never silently breaks another:
- Your binding wins over a default. If you bind
run_all = "ctrl+r", Ctrl+R stops opening History. When an action is left without any key this way, quarry tells you when the TUI starts, and you can give it a new one. - Two of your own bindings on one key: one action keeps it and you get a warning naming both. The action that comes first in the list below wins.
- Alt+1…9 always jump to tabs and can't be rebound.
- Keys the editor uses itself (Ctrl+C, X, V, A, Z, Y, D, /, Space) keep their editor meaning while the editor has focus. A binding on one of them works everywhere else, and quarry warns you about it.
- A plain character such as
?works only when you aren't typing in a text field, so it never gets in the way of your SQL. - An unknown action or key is skipped with a warning; the rest of
[keys]still applies.
Warnings appear as notices when the TUI starts.
Actions you can rebind
Global
| Action | Default keys | Does |
|---|---|---|
commands | Ctrl+P | Command palette |
help | F1, ? | Keyboard shortcuts |
connections | Ctrl+O | Connections |
new_query | Ctrl+T | New query tab (in the explorer: for the selected database) |
close_tab | Ctrl+W | Close tab |
next_tab | Alt+→, Ctrl+PgDn | Next tab |
prev_tab | Alt+←, Ctrl+PgUp | Previous tab |
next_pane | F6 | Focus the next pane: explorer, editor, results |
prev_pane | Shift+F6 | Focus the previous pane |
focus_explorer | Alt+0 | Focus the explorer |
toggle_explorer | Ctrl+B | Show or hide the explorer |
go_to_table | Ctrl+G | Go to a table |
themes | Ctrl+Y | Theme picker |
history | Ctrl+R | Query history |
quit | Ctrl+Q | Quit |
Query tabs
| Action | Default keys | Does |
|---|---|---|
run_statement | Ctrl+Enter, Alt+Enter, Ctrl+E | Run the statement under the cursor, or the selection |
run_all | F5, Ctrl+Shift+Enter | Run everything in the editor |
cancel | Esc, Ctrl+C | Cancel the running query |
explain | F7 | Explain |
explain_analyze | Shift+F7 | Explain analyze |
format_sql | Alt+F | Format the SQL |
save_favorite | Ctrl+S | Save the query as a favourite |
export | Ctrl+X | Export results to a file |
editor_smaller | Ctrl+↑ | Make the editor smaller |
editor_larger | Ctrl+↓ | Make the editor larger |
Keys inside a pane, such as moving in the results grid or the explorer, are fixed. They're listed in Keyboard shortcuts.
Vim mode
Set vi = true under [main]. The REPL gets vi editing, and the TUI's SQL editor gets vim's modes:
- Normal is where you start. The cursor is a block and the status bar says
NORMAL. - Insert (i, a, o, …) is ordinary typing, with completion as you type. The cursor turns into a bar.
- Visual (v) and visual-line (V) select text for an operator.
Esc goes back to normal mode. In normal mode, Esc moves to the results, as it does without vim. The app-wide keys (run, explain, tabs, palette) work in every mode.
| Keys | Do |
|---|---|
| h j k l | Left, down, up, right |
| w b e | Next word, previous word, end of word |
| 0 ^ $ | Line start, first non-blank, line end |
| gg G | First line, last line (5G goes to line 5) |
| Ctrl+D / Ctrl+U | Half a page down / up |
| i a I A | Insert before, after, at line start, at line end |
| o O | New line below / above |
| d c y > < + a motion | Delete, change, yank, indent, dedent: dw, c$, y2j, >G |
| dd cc yy >> << | The same on whole lines |
ciw, diw, yaw | Change, delete, yank a word (a includes the space after it) |
| x X | Delete the character under / before the cursor |
| s S | Replace the character / the line |
| D C Y | Delete / change to the end of the line, yank the line |
| r + a character | Replace the character under the cursor |
| J | Join the next line onto this one |
| p P | Paste after / before. Whole lines go below / above. |
| u, Ctrl+R | Undo, redo |
A number in front repeats: 3j, 2dd, 5x. Yanks and deletes go to the system clipboard, so you can paste them elsewhere, and text copied elsewhere pastes with p.
Not supported: search (/), marks, macros, registers other than the clipboard, . to repeat, and : commands.
Related
- Keyboard shortcuts: every key, including the fixed ones
- Using the TUI
- Configuration file