73 Normal mode commands
Elfogadodhe edited this page 2024-03-28 22:05:01 +01:00

A list of key and commands for normal mode. Meant to supplement the keymap and keys doc - especially for people using alternate keyboard layouts.

The following keys are free for you to customize: 0, D, X, Y, ', #, ^, -, =, and <ret>. See suggestions

Beware of ambiguous keys like <tab> vs <c-i> and <ret> vs <c-j> and <c-m>.

For a bigger table, see Kakoune explain keys

KeyDescriptionALT + keyCTRL + keyg key (goto)
ainsert after selected textselect whole objectlast buffer
Ainsert at line end
bselect to previous word startselect to previous WORD startscroll one page upwindow bottom
Bextend to previous word startextend to previous WORD start
cchange selected textchange selected text without yankingwindow center
Ccopy selection on next linescopy selection on previous lines
derase selected texterase selected text without yankingscroll one half page down
D
eselect to next word endselect to next WORD endbuffer end
Eextend to next word endextend to next WORD end
fselect to next character includedselect to previous character includedscroll one page downfile
Fextend to next character includedextend to previous character included
ggo to location
Gextend to location
hmove leftselect to line beginundo last selection changeline begin
Hextend leftextend to line begin
iinsert before selected textselect inner objectjump forward in jump listline begin (non blank)
Iinsert at line begin
jmove downjoin lines(ambiguous)buffer bottom
Jextend downjoin lines and select spaces
kmove upkeep selections matching given regexredo last selection changebuffer top
Kextend upkeep selections not matching given regex
lmove rightselect to line endforce screen redrawline end
Lextend rightextend to line end
mselect to next matching characterselect to previous matching character(ambiguous)
Mextend to next matching characterextend to previous matching character
nselect next current search pattern matchselect previous current search pattern match
Nextend with next current search pattern matchextend with previous current search pattern match
oinsert on new line belowadd a new empty line belowjump backward in jump list
Oinsert on new line aboveadd a new empty line above
ppaste after selected textpaste every yanked selection after selected text
Ppaste before selected textpaste every yanked selection before selected text
qreplay recorded macro
Qstart or end macro recording
rreplace with character
Rreplace selected text with paired yanked textreplace selected text with all yanked texts
sselect regex matches in selected textsplit selected text on line endspush current selections in jump list
Ssplit selected text on regex matchesselect first and last characters of each selections
tselect to next characterselect to previous characterwindow top
Textend to next characterextend to previous character
uundomove backward in historyscroll one half page up
Uredomove forward in history
vmanipulate view
Vlock view mode
wselect to next word startselect to next WORD start
Wextend to next word startextend to next WORD start
xexpand selections to contain full lines (including end-of-lines)trim selections to only contain full lines (not including last end-of-line)
X
yyank (copy) selected text
Y
zrestore selectionscombine selections from register
Zsave selectionscombine selections to register
external shell commands
!insert command outputappend command output
$pipe each selection through shell command and keep the ones whose command succeed
|pipe each selection through filter and replace with outputpipe each selection through command and ignore output
align / indent
&align cursorscopy indentation
@convert tabs to spacesconvert spaces to tabs
<deindentdeindent, not including incomplete indent
>indentindent, including empty lines
selections
%select whole buffer
(rotate main selection backwardrotate selections content backward
)rotate main selection forwardrotate selections content forward
;
semicolon
reduce selections to their cursorswap cursors and anchors
_trim selectionsmerge contiguous selections together
search
*set search pattern to main selection contentset search pattern to main selection content, do not detect words
/select next given regex matchselect previous given regex match
?extend with next given regex matchextend with previous given regex match
text-objects
[select to object startselect to inner object start
]select to object endselect to inner object end
{extend to object startextend to inner object start
}extend to object endextend to inner object end
text case
`convert to lower caseswap case
~convert to upper case
,clear selections to only keep the main oneclear the main selection
.repeat last insert commandrepeat last object or t/f selection commandlast buffer change
\disable hooks
:enter command promptensure cursor is after anchor
"choose register
'
#
^
-
=
+duplicate each selection (generating overlapping selections)merge overlapping selections
Upmove up
Downmove down
Leftmove left
Rightmove right
Homeselect to line begin
Endselect to line end
PageDownscroll one page down
PageUpscroll one page up
Spaceenter default user mode to access custom commands
Backspaceremove count
Escape
Return
Taboften interpreted as ctrl+i

Suggestions

alt + number offer 10 keys to customize. Example:

map global normal <a-3> ':echo free<ret>'
# vim old habits
map global normal D '<a-l>d' -docstring 'delete to end of line'
map global normal Y '<a-l>y' -docstring 'yank to end of line'
map global normal = :format<ret> -docstring 'format buffer'

map global normal '#' :comment-line<ret> -docstring 'comment line'
map global normal '<a-#>' :comment-block<ret> -docstring 'comment block'

map global goto m '<esc>m;' -docstring 'matching char'

# if you press 0 alone, it will echo "foo".
# if you press 0 after a number to express a count, like 10, it will work as usual.
map global normal 0 ':zero "echo foo"<ret>'
define-command zero -params 1 %{ evaluate-commands %sh{
  if [ $kak_count = 0 ]; then
    echo "$1"
  else
    echo "exec ${kak_count}0"
  fi
}}