= Keys == Key Syntax Usual keys are written using their ascii character, including capital keys. Non printable keys use an alternate name, written between *<* and *>*, such as ** or **. Modified keys are written between *<* and *>* as well, with the modifier specified as either *c* for Control, *a* for Alt, or *s* for Shift, followed by a *-* and the key (either its name or ascii character), for example **, **, **. In order to bind some keys to arbitrary ones, refer to <> == Insert mode **:: leave insert mode **:: delete characters before cursors **:: delete characters under cursors **, **, **, **:: move the cursors in given direction **:: move cursors to line begin **:: move cursors to end of line **:: insert contents of the register given by next key **:: insert next keystroke directly into the buffer, without interpreting it **:: commit changes up to now as a single undo group **:: escape to normal mode for a single command == Insert mode completion The `completers` option controls automatic completion, which kicks in when the value specified in the `idle_timeout` option is reached. **:: toggle automatic completion **:: select next completion candidate **:: select previous completion candidate **:: explicit insert completion query, followed by: *f*::: explicit file completion *w*::: explicit word completion (current buffer) *W*::: explicit word completion (all buffers) *l*::: explicit line completion (current buffer) *L*::: explicit line completion (all buffers) == Using Counts In normal mode, commands can be prefixed with a numeric count, which can control the command behaviour. For example, *3W* selects 3 consecutive words and *3w* select the third word on the right of the end of each selection. == Disabling Hooks Any normal mode command can be prefixed with *\* which will disable hook execution for the duration for the command (including the duration of modes the command could move to, so *\i* will disable hooks for the whole insert session). As autoindentation is implemented in terms of hooks, this can be used to disable it when pasting text. == Movement 'word' is a sequence of alphanumeric characters or underscore, and 'WORD' is a sequence of non whitespace characters. Generally, a movement on it own will move each selection to cover the text moved over, while holding down the Shift modifier and moving will extend each selection instead. *h*, **:: select the character on the left of the end of each selection *j*, **:: select the character below the end of each selection *k*, **:: select the character above the end of each selection *l*, **:: select the character on the right of the end of each selection *w*:: select the word and following whitespaces on the right of the end of each selection *b*:: select preceding whitespaces and the word on the left of the end of each selection *e*:: select preceding whitespaces and the word on the right of the end of each selection **:: same as [wbe] but select WORD instead of word *f*:: select to the next occurrence of given character *t*:: select until the next occurrence of given character **:: same as [ft] but in the other direction **:: repeat last object or *f*/*t* selection command *m*:: select to the next sequence enclosed by matching character, see the `matching_pairs` option in <> *x*:: select line on which the end of each selection lies (or next line when end lies on an end-of-line) **:: expand selections to contain full lines (including end-of-lines) **:: trim selections to only contain full lines (not including last end-of-line) *%*:: select whole buffer **, **:: select to line begin **, **:: select to line end *pageup, *:: scroll one page up *pagedown, *:: scroll one page down **:: scroll half a page up **:: scroll half a page down *;*:: reduce selections to their cursor **:: flip the direction of each selection **:: ensure selections are in forward direction (cursor after anchor) == Changes Yanking (copying) and pasting use the *"* register by default (See <>) *i*:: enter insert mode before selections *a*:: enter insert mode after selections *d*:: yank and delete selections *c*:: yank and delete selections and enter insert mode *.*:: repeat last insert mode change (*i*, *a*, or *c*, including the inserted text) **:: delete selections (not yanking) **:: delete selections and enter insert mode (not yanking) *I*:: enter insert mode at the beginning of the lines containing the start of each selection *A*:: enter insert mode at the end of the lines containing the end of each selection *o*:: enter insert mode in a new line (or in a given count of new lines) below the end of each selection *O*:: enter insert mode in a new line (or in a given count of new lines) above the beginning of each selection **:: add an empty line below cursor **:: add an empty line above cursor *y*:: yank selections *p*:: paste after the end of each selection *P*:: paste before the beginning of each selection **:: paste all after the end of each selection, and select each pasted string **:: paste all before the start of each selection, and select each pasted string *R*:: replace selections with yanked text **:: replace selections with every yanked text *r*:: replace each character with the next entered one **:: join selected lines **:: join selected lines and select spaces inserted in place of line breaks **:: merge contiguous selections together (works across lines as well) *>*:: indent selected lines *>*:: indent selected lines, including empty lines *<*:: deindent selected lines **:: deindent selected lines, do not remove incomplete indent (3 leading spaces when indent is 4) *u*:: undo last change **:: move backward in history *U*:: redo last change **:: move forward in history *&*:: align selections, align the cursor of each selection by inserting spaces before the first character of each selection **:: copy indent, copy the indentation of the main selection (or the count one if a count is given) to all other ones *`*:: to lower case *~*:: to upper case **:: swap case *@*:: convert tabs to spaces in each selection, uses the buffer tabstop option or the count parameter for tabstop **:: convert spaces to tabs in each selection, uses the buffer tabstop option or the count parameter for tabstop *_*:: unselect whitespace surrounding each selection, drop those that only contain whitespace **:: rotate selections content, if specified, the count groups selections, so the following command ---------- 3 ---------- rotate (1, 2, 3) and (3, 4, 6) independently **:: rotate selections content backward == Changes through external programs Shell expansions are available, (See <>) The default command comes from the *|* register by default (See <>) *|*:: pipe each selection through the given external filter program and replace the selection with its output. **:: pipe each selection through the given external filter program and ignore its output. *!*:: insert command output before each selection. **:: append command output after each selection. == Searching Searches use the */* register by default (See <>) */*:: select next match after each selection **:: select previous match before each selection *?*:: extend to next match after each selection **:: extend to previous match before each selection *n*:: select next match after the main selection *N*:: add a new selection with next match after the main selection **:: select previous match before the main selection **:: add a new selection with previous match before the main selection ***:: set the search pattern to the main selection (automatically detects word boundaries) **:: set the search pattern to the main selection (verbatim, no smart detection) == Goto commands *g*, *G*:: When a count is specified, *G* only extends the selection to the given line, *g* sends the anchor to the given line and a menu is then displayed which waits for one of the following additional keys: *h*::: go to line begin *l*::: go to line end *i*::: go to non blank line start *g*, *k*::: go to the first line *j*::: go to the last line *e*::: go to last char of last line *t*::: go to the first displayed line *c*::: go to the middle displayed line *b*::: go to the last displayed line *a*::: go to the previous (alternate) buffer *f*::: open the file whose name is selected *.*::: go to last buffer modification position == View commands *v*, *V*:: *V* enters lock view mode (which will be left when the is hit), and *v* modifies the current view; a menu is then displayed which waits for one of the following additional keys: *v*, *c*::: center the main selection in the window (vertically) *m*::: center the main selection in the window (horizontally) *t*::: scroll to put the main selection on the top line of the window *b*::: scroll to put the main selection on the bottom line of the window *h*::: scroll the window count columns left *j*::: scroll the window count line downward *k*::: scroll the window count line upward *l*::: scroll the window count columns right == Marks Current selections position can be saved in a register and restored later on. Marks use the *^* register by default (See <>) *Z*:: save selections to the register *z*:: restore selections from the register **, **:: ** combines selections from the register with the current ones, whereas ** combines current selections with the ones in the register; a menu is then displayed which waits for one of the following additional keys: *a*::: append selections *u*::: keep a union of selections *i*::: keep an intersection of selections *<*::: select the selection with the leftmost cursor for each pair *>*::: select the selection with the rightmost cursor for each pair *+*::: select the longest selection *-*::: select the shortest selection == Macros Macros use the *@* register by default (See <>) *Q*:: start or end macro recording *q*:: play a recorded macro **:: end macro recording == Jump list Some commands, like the goto commands, buffer switch or search commands, push the previous selections to the client's jump list. It is possible to skim through the jump list using: **:: jump forward **:: jump backward **:: save selections == Multiple selections *s*, *S*, ** and ** use the */* register by default (See <>) *s*:: create a selection for each match of the given regex *S*:: split selections with the given regex **:: split selections on line boundaries **:: select first and last characters of each selection *C*:: copy the main selection to the next line **:: copy the main selection to the previous line **:: clear selections to only keep the main one **:: clear the main selection **:: keep selections that match the given regex **:: clear selections that match the given regex *$*:: pipe each selection to the given shell command and keep the ones for which the shell returned 0. Shell expansions are available, (See <>) *)*:: rotate main selection (the main selection becomes the next one) *(*:: rotate main selection backward (the main selection becomes the previous one) == Object Selection For nestable objects, a count can be used in order to specify which surrounding level to select. Object selections are repeatable using **. === Whole object A 'whole object' is an object *including* its surrounding characters. For example, for a quoted string this will select the quotes, and for a word this will select trailing spaces. **:: select the whole object *[*:: select to the whole object start *]*:: select to the whole object end *{*:: extend selections to the whole object start *}*:: extend selections to the whole object end === Inner object An 'inner object' is an object *excluding* its surrounding characters. For example, for a quoted string this will *not* select the quotes, and for a word this will *not* select trailing spaces. **:: select the inner object **:: select to the inner object start **:: select to the inner object end **:: extend selections to the inner object start **:: extend selections to the inner object end === Objects types After the keys described above, a second key needs to be entered in order to specify the wanted object: *b*, *(*, *)*:: select the enclosing parenthesis *B*, *{*, *}*:: select the enclosing {} block *r*, *[*, *]*:: select the enclosing [] block *a*, *<*, *>*:: select the enclosing <> block *Q*, *"*:: select the enclosing double quoted string *q*, *'*:: select the enclosing single quoted string *g*, *`*:: select the enclosing grave quoted string *w*:: select the whole word **:: select the whole WORD *s*:: select the sentence *p*:: select the paragraph *␣*:: select the whitespaces *i*:: select the current indentation block *n*:: select the number *u*:: select the argument *c*:: select user defined object, will prompt for open and close text == Prompt commands When pressing `:` in normal mode, Kakoune will open a prompt to enter a command. The executed command line is stored in the *:* register (See <>). During edition, a transient *clipboard* is available, its content is empty at the start of prompt edition, and is not preserved afterwards. The following keys are recognized by this mode to help with editing (See <>). **:: validate prompt **:: abandon without **, **:: move cursor to previous character **, **:: move cursor to next character **, **:: move cursor to first character **, **:: move cursor past the last character **, **:: erase character before cursor **, **:: erase character under cursor **:: advance to next word begin **:: advance to next WORD begin **:: go back to previous word begin **:: go back to previous WORD begin **:: advance to next word end **:: advance to next WORD end **:: erase to previous word begin, save erased content to *clipboard* **:: erase to previous WORD begin, save erased content to *clipboard* **:: erase to previous word end, save erased content to *clipboard* **:: erase to previous WORD end, save erased content to *clipboard* **:: erase to end of line, save erased content to *clipboard* **:: erase to begin of line, save erased content to *clipboard* **:: insert *clipboard* content before cursor **, **:: select previous entry in history **, **:: select next entry in history **:: select next completion candidate **:: select previous completion candidate **:: insert then content of the register given by next key **:: insert next keystroke without interpreting it **:: toggle automatic completion **:: expand the typed expansions in currently entered text (See <>) **:: escape to normal mode for a single command