# Vim mode

Two message inputs. In the Web composer the mode label sits at the end of the first line, inside the input, before the send button. In the TUI it sits at the right end of the input box. The label reads INSERT while typing and NORMAL after Escape.

| Way | Effect |
| --- | --- |
| `/vim` | Turns Vim mode on, or off if it is on |
| `/vim on`, `/vim off` | Sets it either way |
| `openprogram config set editor.vim_mode true` | The same setting from a shell |

Off by default. The setting is saved in `config.json` and every open input follows it: the TUI, the Web and App composer, and the box for editing a sent message. Off, the input looks and works as without it.

## Modes

| Key | Result |
| --- | --- |
| Typing | INSERT, where keys type as usual. Each new message starts here. |
| Esc | INSERT to NORMAL. An open command or file menu closes first. |
| Esc in NORMAL | Cancels a half-typed command; with none, stops a running turn |
| `i` `a` `I` `A` `o` `O` | Back to INSERT: before or after the cursor, at the line's start or end, on a new line below or above |
| Enter | Sends, in either mode |

## NORMAL keys

| Group | Keys | Does |
| --- | --- | --- |
| Move | `h j k l` `w b e` `W B E` `0 ^ $` `gg G` `f F t T ; ,` | Character, line, word, line ends, first or last line, to a character |
| Operate | `d` `c` `y` + a move, `iw` or `aw`; `dd cc yy` | Delete, change, copy that span; doubled, whole lines |
| Edit | `x X s S D C Y r` `p P` | Delete or change a character or the line's rest, replace a character, paste after or before |
| History | `u` `Ctrl-r` `.` | Undo, redo, repeat the last change |
| Count | `3w` `2dd` `d2w` `3.` | A number first repeats |

One INSERT stretch is one undo step. Not included: Visual mode, named registers, macros, search and `:` commands. Arrow keys, Tab and shortcuts keep their usual job in both modes; in the TUI, `Ctrl-r` in INSERT still opens context search.
