1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-28 06:08:05 +03:00
kakoune/doc/pages/keys.asciidoc

712 lines
15 KiB
Plaintext
Raw Normal View History

= 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 *<esc>* or *<del>*. 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 *<c-x>*, *<a-space>*, *<c-a-w>*.
2017-11-06 12:08:59 +03:00
In order to bind some keys to arbitrary ones, refer to <<mapping#,`:doc mapping`>>
== Insert mode
*<esc>*::
2017-11-02 12:37:39 +03:00
leave insert mode
*<backspace>*::
2017-11-02 12:37:39 +03:00
delete characters before cursors
*<del>*::
2017-11-02 12:37:39 +03:00
delete characters under cursors
*<left>*, *<right>*, *<up>*, *<down>*::
2017-11-02 12:37:39 +03:00
move the cursors in given direction
*<home>*::
2017-11-02 12:37:39 +03:00
move cursors to line begin
*<end>*::
2017-11-02 12:37:39 +03:00
move cursors to end of line
*<c-r>*::
insert contents of the register given by next key
*<c-v>*::
insert next keystroke directly into the buffer, without interpreting it
*<c-u>*::
commit changes up to now as a single undo group
*<a-;>*::
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.
*<c-o>*::
disable automatic completion for this insert session
*<c-n>*::
2017-11-02 12:37:39 +03:00
select next completion candidate
*<c-p>*::
2017-11-02 12:37:39 +03:00
select previous completion candidate
*<c-x>*::
2017-11-02 12:37:39 +03:00
explicit insert completion query, followed by:
2017-11-02 12:37:39 +03:00
*f*:::
explicit file completion
2017-11-02 12:37:39 +03:00
*w*:::
explicit word completion (current buffer)
2017-11-02 12:37:39 +03:00
*W*:::
explicit word completion (all buffers)
2017-11-02 12:37:39 +03:00
*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
2016-02-11 00:03:49 +03:00
'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*, *<left>*::
select the character on the left of the end of each selection
*j*, *<down>*::
select the character below the end of each selection
*k*, *<up>*::
select the character above the end of each selection
*l*, *<right>*::
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
*<a-[wbe]>*::
2017-11-02 12:37:39 +03:00
same as [wbe] but select WORD instead of word
*f*::
2017-11-02 12:37:39 +03:00
select to the next occurrence of given character
*t*::
2017-11-02 12:37:39 +03:00
select until the next occurrence of given character
*<a-[ft]>*::
2017-11-02 12:37:39 +03:00
same as [ft] but in the other direction
*m*::
2017-11-06 12:08:59 +03:00
select to matching character, see the `matching_pairs` option
in <<options#,`:doc options`>>
*x*::
select line on which the end of each selection lies (or next line when end lies
2017-11-02 12:37:39 +03:00
on an end-of-line)
*<a-x>*::
2017-11-02 12:37:39 +03:00
expand selections to contain full lines (including end-of-lines)
*<a-X>*::
2017-11-02 12:37:39 +03:00
trim selections to only contain full lines (not including last
end-of-line)
*%*::
2017-11-02 12:37:39 +03:00
select whole buffer
*<a-h>*, *<home>*::
2017-11-02 12:37:39 +03:00
select to line begin
*<a-l>*, *<end>*::
2017-11-02 12:37:39 +03:00
select to line end
*/*::
2017-11-02 12:37:39 +03:00
search (select next match)
*<a-/>*::
2017-11-02 12:37:39 +03:00
search (select previous match)
*?*::
2017-11-02 12:37:39 +03:00
search (extend to next match)
*<a-?>*::
2017-11-02 12:37:39 +03:00
search (extend to previous match)
*n*::
2017-11-02 12:37:39 +03:00
select next match
*N*::
2017-11-02 12:37:39 +03:00
add a new selection with next match
*<a-n>*::
2017-11-02 12:37:39 +03:00
select previous match
*<a-N>*::
2017-11-02 12:37:39 +03:00
add a new selection with previous match
*pageup, <c-b>*::
2017-11-02 12:37:39 +03:00
scroll one page up
*pagedown, <c-f>*::
2017-11-02 12:37:39 +03:00
scroll one page down
*<c-u>*::
2017-11-02 12:37:39 +03:00
scroll half a page up
*<c-d>*::
2017-11-02 12:37:39 +03:00
scroll half a page down
*;*::
2017-11-02 12:37:39 +03:00
reduce selections to their cursor
*<a-;>*::
flip the direction of each selection
*<a-:>*::
2017-11-02 12:37:39 +03:00
ensure selections are in forward direction (cursor after anchor)
*<a-.>*::
2017-11-02 12:37:39 +03:00
repeat last object or *f*/*t* selection command
== Changes
*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
*.*::
2017-11-02 12:37:39 +03:00
repeat last insert mode change (*i*, *a*, or *c*, including the
inserted text)
*<a-d>*::
delete selections (not yanking)
*<a-c>*::
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
*<a-o>*::
2017-11-02 12:37:39 +03:00
add an empty line below cursor
*<a-O>*::
2017-11-02 12:37:39 +03:00
add an empty line above cursor
*y*::
2017-11-02 12:37:39 +03:00
yank selections
*p*::
paste after the end of each selection
*P*::
paste before the beginning of each selection
*<a-p>*::
paste all after the end of each selection, and select each pasted string
*<a-P>*::
paste all before the start of each selection, and select each pasted string
*R*::
replace selections with yanked text
*<a-R>*::
replace selections with every yanked text
*r*::
2017-11-02 12:37:39 +03:00
replace each character with the next entered one
*<a-j>*::
2017-11-02 12:37:39 +03:00
join selected lines
*<a-J>*::
2017-11-02 12:37:39 +03:00
join selected lines and select spaces inserted in place of line breaks
*<a-m>*::
2017-11-02 12:37:39 +03:00
merge contiguous selections together (works across lines as well)
*>*::
2017-11-02 12:37:39 +03:00
indent selected lines
*<a\->>*::
2017-11-02 12:37:39 +03:00
indent selected lines, including empty lines
*<*::
2017-11-02 12:37:39 +03:00
deindent selected lines
*<a-<>*::
2017-11-02 12:37:39 +03:00
deindent selected lines, do not remove incomplete indent (3 leading
spaces when indent is 4)
2016-02-11 00:03:49 +03:00
*|*::
2017-11-02 12:37:39 +03:00
pipe each selection through the given external filter program and
replace the selection with its output. Shell expansions are available,
(See <<expansions#shell-expansions,`:doc expansions shell-expansions`>>)
2016-02-11 00:03:49 +03:00
*<a-|>*::
2017-11-02 12:37:39 +03:00
pipe each selection through the given external filter program and
ignore its output. Shell expansions are available,
(See <<expansions#shell-expansions,`:doc expansions shell-expansions`>>)
*!*::
insert command output before each selection. Shell expansions are available,
(See <<expansions#shell-expansions,`:doc expansions shell-expansions`>>)
*<a-!>*::
append command output after each selection. Shell expansions are available,
(See <<expansions#shell-expansions,`:doc expansions shell-expansions`>>)
*u*::
2017-11-02 12:37:39 +03:00
undo last change
*<a-u>*::
2017-11-02 12:37:39 +03:00
move backward in history
*U*::
2017-11-02 12:37:39 +03:00
redo last change
*<a-U>*::
2017-11-02 12:37:39 +03:00
move forward in history
*&*::
align selections, align the cursor of each selection by inserting spaces
before the first character of each selection
*<a-&>*::
2017-11-02 12:37:39 +03:00
copy indent, copy the indentation of the main selection (or the
count one if a count is given) to all other ones
*`*::
2017-11-02 12:37:39 +03:00
to lower case
*~*::
2017-11-02 12:37:39 +03:00
to upper case
*<a-`>*::
2017-11-02 12:37:39 +03:00
swap case
*@*::
convert tabs to spaces in each selection, uses the buffer tabstop
2017-11-02 12:37:39 +03:00
option or the count parameter for tabstop
*<a-@>*::
convert spaces to tabs in each selection, uses the buffer tabstop
2017-11-02 12:37:39 +03:00
option or the count parameter for tabstop
2018-02-13 16:35:10 +03:00
*_*::
trim selections
*<a-)>*::
2017-11-02 12:37:39 +03:00
rotate selections content, if specified, the count groups selections,
so the following command
----------
2018-04-19 19:55:41 +03:00
3<a-)>
----------
2017-11-02 12:37:39 +03:00
rotate (1, 2, 3) and (3, 4, 6) independently
*<a-(>*::
rotate selections content backward
== Goto commands
*g*, *G*::
When a count is specified, *G* only extends the selection to the given line,
2017-11-02 12:37:39 +03:00
*g* sends the anchor to the given line and a menu is then displayed which waits
for one of the following additional keys:
2017-11-02 12:37:39 +03:00
*h*:::
go to line begin
2017-11-02 12:37:39 +03:00
*l*:::
go to line end
2017-11-02 12:37:39 +03:00
*i*:::
go to non blank line start
2017-11-02 12:37:39 +03:00
*g*, *k*:::
go to the first line
2017-11-02 12:37:39 +03:00
*j*:::
go to the last line
2017-11-02 12:37:39 +03:00
*e*:::
go to last char of last line
2017-11-02 12:37:39 +03:00
*t*:::
go to the first displayed line
2017-11-02 12:37:39 +03:00
*c*:::
go to the middle displayed line
2017-11-02 12:37:39 +03:00
*b*:::
go to the last displayed line
2017-11-02 12:37:39 +03:00
*a*:::
go to the previous (alternate) buffer
2017-11-02 12:37:39 +03:00
*f*:::
open the file whose name is selected
2017-11-02 12:37:39 +03:00
*.*:::
go to last buffer modification position
== View commands
*v*, *V*::
2017-11-02 12:37:39 +03:00
*V* enters lock view mode (which will be left when the <esc> is hit),
and *v* modifies the current view; a menu is then displayed which waits
for one of the following additional keys:
2017-11-02 12:37:39 +03:00
*v*, *c*:::
center the main selection in the window (vertically)
2017-11-02 12:37:39 +03:00
*m*:::
center the main selection in the window (horizontally)
2017-11-02 12:37:39 +03:00
*t*:::
scroll to put the main selection on the top line of the window
2017-11-02 12:37:39 +03:00
*b*:::
scroll to put the main selection on the bottom line of the window
2017-11-02 12:37:39 +03:00
*h*:::
scroll the window count columns left
2017-11-02 12:37:39 +03:00
*j*:::
scroll the window count line downward
2017-11-02 12:37:39 +03:00
*k*:::
scroll the window count line upward
2017-11-02 12:37:39 +03:00
*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 <<registers#,`:doc registers`>>)
*Z*::
save selections to the register
*z*::
restore selections from the register
*<a-z>*, *<a-Z>*::
*<a-z>* combines selections from the register with the current ones, whereas
*<a-Z>* combines current selections with the ones in the register; a menu
is then displayed which waits for one of the following additional keys:
2017-11-02 12:37:39 +03:00
*a*:::
append selections
2017-11-02 12:37:39 +03:00
*u*:::
keep a union of selections
2017-11-02 12:37:39 +03:00
*i*:::
keep an intersection of selections
2017-11-02 12:37:39 +03:00
*<*:::
select the selection with the leftmost cursor for each pair
2017-11-02 12:37:39 +03:00
*>*:::
select the selection with the rightmost cursor for each pair
2017-11-02 12:37:39 +03:00
*+*:::
select the longest selection
2017-11-02 12:37:39 +03:00
*-*:::
select the shortest selection
== Macros
Macros use the *@* register by default (See <<registers#,`:doc registers`>>)
*Q*::
2017-11-02 12:37:39 +03:00
start or end macro recording
*q*::
2017-11-02 12:37:39 +03:00
play a recorded macro
*<esc>*::
end macro recording
== Searching
Searches use the */* register by default (See <<registers#,`:doc registers`>>)
***::
set the search pattern to the main selection (automatically
2017-11-02 12:37:39 +03:00
detects word boundaries)
*<a-***>*::
set the search pattern to the main selection (verbatim, no smart
2017-11-02 12:37:39 +03:00
detection)
== 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:
*<c-i>*::
jump forward
*<c-o>*::
jump backward
*<c-s>*::
save selections
== Multiple selections
*s*::
create a selection for each match of the given regex
*S*::
split selections with the given regex
*<a-s>*::
split selections on line boundaries
*<a-S>*::
select first and last characters of each selection
*C*::
copy the main selection to the next line
*<a-C>*::
copy the main selection to the previous line
*<space>*::
clear selections to only keep the main one
*<a-space>*::
clear the main selection
*<a-k>*::
keep selections that match the given regex
*<a-K>*::
2017-11-02 12:37:39 +03:00
clear selections that match the given regex
*$*::
2017-11-02 12:37:39 +03:00
pipe each selection to the given shell command and keep the ones
for which the shell returned 0. Shell expansions are available,
(See <<expansions#shell-expansions,`:doc expansions shell-expansions`>>)
*)*::
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.
*<a-a>*::
select the whole object
*<a-i>*::
select the inner object, that is the object excluding its surrounder.
For example, for a quoted string, this will not select the quote, and
for a word this will not select trailing spaces.
*[*::
select to object start
*]*::
select to object end
*{*::
extend selections to object start
*}*::
extend selections to object end
After these keys, a second key needs to be entered in order to specify
the wanted object:
*b*, *(*, *)*::
2017-11-02 12:37:39 +03:00
select the enclosing parenthesis
*B*, *{*, *}*::
2017-11-02 12:37:39 +03:00
select the enclosing {} block
*r*, *[*, *]*::
2017-11-02 12:37:39 +03:00
select the enclosing [] block
*a*, *<*, *>*::
2017-11-02 12:37:39 +03:00
select the enclosing <> block
*Q*, *"*::
2017-11-02 12:37:39 +03:00
select the enclosing double quoted string
*q*, *'*::
2017-11-02 12:37:39 +03:00
select the enclosing single quoted string
*g*, *`*::
2017-11-02 12:37:39 +03:00
select the enclosing grave quoted string
*w*::
2017-11-02 12:37:39 +03:00
select the whole word
*<a-w>*::
2017-11-02 12:37:39 +03:00
select the whole WORD
*s*::
2017-11-02 12:37:39 +03:00
select the sentence
*p*::
2017-11-02 12:37:39 +03:00
select the paragraph
*␣*::
2017-11-02 12:37:39 +03:00
select the whitespaces
*i*::
2017-11-02 12:37:39 +03:00
select the current indentation block
*n*::
2017-11-02 12:37:39 +03:00
select the number
*u*::
2017-11-02 12:37:39 +03:00
select the argument
*c*::
2017-11-02 12:37:39 +03:00
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 following keys are recognized by this mode to help edition.
(See <<commands#,`:doc commands`>>)
*<ret>*::
2017-11-02 12:37:39 +03:00
validate prompt
*<esc>*::
2017-11-02 12:37:39 +03:00
abandon without
*<left>*, *<a-h>*::
2017-11-02 12:37:39 +03:00
move cursor to previous character
*<right>*, *<a-l>*::
2018-03-09 11:22:06 +03:00
move cursor to next character
*<home>*::
2017-11-02 12:37:39 +03:00
move cursor to first character
*<end>*::
2017-11-02 12:37:39 +03:00
move cursor past the last character
*<backspace>*, *<a-x>*::
2017-11-02 12:37:39 +03:00
erase character before cursor
*<del>*, *<a-d>*::
2017-11-02 12:37:39 +03:00
erase character under cursor
*<c-w>*::
advance to next word begin
*<c-a-w>*::
2017-11-02 12:37:39 +03:00
advance to next WORD begin
*<c-b>*::
2017-11-02 12:37:39 +03:00
go back to previous word begin
*<c-a-b>*::
2017-11-02 12:37:39 +03:00
go back to previous WORD begin
*<c-e>*::
2017-11-02 12:37:39 +03:00
advance to next word end
*<c-a-e>*::
2017-11-02 12:37:39 +03:00
advance to next word end
*<up>*, *<c-p>*::
2017-11-02 12:37:39 +03:00
select previous entry in history
*<down>*, *<c-n>*::
2017-11-02 12:37:39 +03:00
select next entry in history
*<tab>*::
2017-11-02 12:37:39 +03:00
select next completion candidate
*<s-tab>*::
2017-11-02 12:37:39 +03:00
select previous completion candidate
*<c-r>*::
2017-11-02 12:37:39 +03:00
insert then content of the register given by next key
*<c-v>*::
2017-11-02 12:37:39 +03:00
insert next keystroke without interpreting it
*<c-o>*::
2017-11-02 12:37:39 +03:00
disable auto completion for this prompt
*<a-!>*::
expand the typed expansions in currently entered text
(See <<expansions#typed-expansions,`:doc expansions typed-expansions`>>)