> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-fix-oracle-native-encryption-login-timeout.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vim Mode

> Modal editing in the SQL editor.

# Vim Mode

Turn on vim mode in **Settings > Editor > Vim mode**. A badge next to the editor shows the current mode.

## Modes

| Mode         | How to enter                                           |
| ------------ | ------------------------------------------------------ |
| Normal       | `Esc`                                                  |
| Insert       | `i`, `I`, `a`, `A`, `o`, `O`, `s`, `S`, `c`, `C`, `gi` |
| Replace      | `R`                                                    |
| Visual       | `v`                                                    |
| Visual Line  | `V`                                                    |
| Command line | `:`, `/`, `?`                                          |

`gi` puts you back where you last left insert.

## Move the cursor

### Characters

| Key             | Goes to                 |
| --------------- | ----------------------- |
| `h` `j` `k` `l` | Left, down, up, right   |
| `0`             | Start of line           |
| `^` `_`         | First non-blank on line |
| `$`             | End of line             |

### Words

| Key         | Goes to                             |
| ----------- | ----------------------------------- |
| `w` `b` `e` | Next word, prev word, word end      |
| `W` `B` `E` | Same, whitespace-only word boundary |
| `ge` `gE`   | Prev word end, prev WORD end        |

### Lines and pages

| Key         | Goes to                     |
| ----------- | --------------------------- |
| `gg`        | First line                  |
| `G`         | Last line                   |
| `5G`        | Line 5                      |
| `H` `M` `L` | Top, middle, bottom of view |
| `%`         | Matching `()`, `[]`, `{}`   |

### Find a character

| Key     | Goes to                             |
| ------- | ----------------------------------- |
| `f{c}`  | Next `{c}` on this line             |
| `F{c}`  | Prev `{c}` on this line             |
| `t{c}`  | Just before next `{c}`              |
| `T{c}`  | Just after prev `{c}`               |
| `;` `,` | Repeat last find, reverse last find |

### Sentences and paragraphs

| Key       | Goes to                              |
| --------- | ------------------------------------ |
| `(` `)`   | Prev sentence, next sentence         |
| `{` `}`   | Prev blank line, next blank line     |
| `[[` `]]` | Prev `{`-at-col-0, next `{`-at-col-0 |

Counts work: `3w` moves three words, `5j` moves five lines down.

## Edit

| Key                     | Action                                      |
| ----------------------- | ------------------------------------------- |
| `d{m}`                  | Delete (with motion)                        |
| `c{m}`                  | Change (delete then enter insert)           |
| `y{m}`                  | Yank                                        |
| `dd` `cc` `yy`          | Same on the whole line                      |
| `D` `C` `Y`             | Same as `d$`, `c$`, `yy`                    |
| `x` `X`                 | Delete one char under, one before cursor    |
| `s` `S`                 | Replace one char or whole line, then insert |
| `r{c}`                  | Replace one char with `{c}`, stay in normal |
| `~`                     | Toggle case under cursor                    |
| `g~{m}` `gu{m}` `gU{m}` | Toggle, lower, upper with motion            |
| `g~~` `guu` `gUU`       | Same on the whole line                      |
| `>>` `<<`               | Indent, outdent line                        |
| `>{m}` `<{m}`           | Indent, outdent with motion                 |
| `J`                     | Join next line with a space                 |
| `gJ`                    | Join next line, no space                    |

`2d3w` deletes six words. `3yy` yanks three lines. `5>>` indents five lines.

Yank, delete, and change all write to the system clipboard.

## Text objects

Use after `d`, `c`, `y`, or in visual mode.

| Object                 | Inside             | Around             |
| ---------------------- | ------------------ | ------------------ |
| Word                   | `iw`               | `aw`               |
| WORD                   | `iW`               | `aW`               |
| `"` `'` `` ` `` string | `i"` `i'` `` i` `` | `a"` `a'` `` a` `` |
| `(` `)` parens         | `i(` `ib`          | `a(` `ab`          |
| `{` `}` braces         | `i{` `iB`          | `a{` `aB`          |
| `[` `]` brackets       | `i[`               | `a[`               |
| `<` `>` angles         | `i<`               | `a<`               |
| HTML tag               | `it`               | `at`               |
| Paragraph              | `ip`               | `ap`               |

`ciw` rewrites the current word. `da"` removes a quoted string and its trailing space. `yip` copies the current paragraph.

## Paste

| Key  | Action                                             |
| ---- | -------------------------------------------------- |
| `p`  | After cursor (or below the line for linewise yank) |
| `P`  | Before cursor (or above the line)                  |
| `3p` | Paste three times                                  |

In visual mode, `p` and `P` replace the selection with the register.

## Registers

Prefix with `"{a-z}` to pick a register.

| Register    | Holds                               |
| ----------- | ----------------------------------- |
| `"`         | Last yank or delete                 |
| `"a` … `"z` | Named, overwrite                    |
| `"A` … `"Z` | Same, append                        |
| `"0`        | Last yank only                      |
| `"1` … `"9` | Delete ring, rotates on each delete |

`"ayy` stores a line in `a`. `"ap` pastes it back later.

## Marks

| Key               | Action                                     |
| ----------------- | ------------------------------------------ |
| `m{a-z}`          | Set mark                                   |
| `` `{a-z} ``      | Jump to exact mark                         |
| `'{a-z}`          | Jump to first non-blank of the mark's line |
| `` `< `` `` `> `` | Start, end of last visual selection        |
| `''` ` ` \`\`     | Back to position before the last jump      |

Marks shift when you insert or delete text before them.

## Search

| Key                | Action                                    |
| ------------------ | ----------------------------------------- |
| `/pattern` `Enter` | Forward search                            |
| `?pattern` `Enter` | Backward search                           |
| `n` `N`            | Next, previous match                      |
| `*` `#`            | Search word under cursor, forward or back |

Searches wrap around.

## Repeat and undo

| Key      | Action                      |
| -------- | --------------------------- |
| `.`      | Repeat last change          |
| `u`      | Undo                        |
| `U`      | Undo all edits on this line |
| `Ctrl+R` | Redo                        |

`5.` repeats the last change five times.

## Macros

| Key      | Action                          |
| -------- | ------------------------------- |
| `q{a-z}` | Start recording into a register |
| `q`      | Stop recording                  |
| `@{a-z}` | Play back                       |
| `@@`     | Play back the last macro        |
| `3@a`    | Play three times                |

Recursion is capped at 50 to keep self-calling macros safe.

## Scroll

| Key               | Action                                  |
| ----------------- | --------------------------------------- |
| `Ctrl+D` `Ctrl+U` | Half page down, up                      |
| `Ctrl+F` `Ctrl+B` | Full page down, up                      |
| `Ctrl+E` `Ctrl+Y` | One line down, up                       |
| `zt` `zz` `zb`    | Put current line at top, middle, bottom |
| `gj` `gk`         | Down, up by visual line                 |

## Visual mode

Motions extend the selection. Then:

| Key         | Action                             |
| ----------- | ---------------------------------- |
| `d` `x`     | Delete                             |
| `c`         | Delete and insert                  |
| `y`         | Yank                               |
| `J` `gJ`    | Join lines                         |
| `~` `u` `U` | Toggle, lower, upper case          |
| `r{c}`      | Replace each char with `{c}`       |
| `>` `<`     | Indent, outdent                    |
| `o`         | Move cursor to the other end       |
| `I` `A`     | Insert at start, end of selection  |
| `gv`        | Reselect the last visual selection |

## Insert mode shortcuts

| Key      | Action                    |
| -------- | ------------------------- |
| `Ctrl+W` | Delete the previous word  |
| `Ctrl+U` | Delete back to line start |
| `Ctrl+H` | Backspace                 |
| `Ctrl+T` | Indent line               |
| `Ctrl+D` | Outdent line              |
| `Esc`    | Back to normal            |

## Numbers

`Ctrl+A` adds one to the next number on the line. `Ctrl+X` subtracts one. Both honour a count (`5 Ctrl+A`), negative numbers, and `0x` hex.

## Command line

| Command    | Action                |
| ---------- | --------------------- |
| `:w`       | Run the current query |
| `:q`       | Close the tab         |
| `:wq` `:x` | Both                  |

`/` and `?` are search. Other `:` commands are parsed and ignored.
