Skip to content

Normal mode commands

Bruno Heridet edited this page Oct 27, 2018 · 49 revisions

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

By default, the Alt-key doesn’t work in Mac OSX-Terminal. Today I found a simple solution for this problem: Terminal > Preferences > Settings > Keyboard Just check ‘Use option as meta key’ at the bottom and you’re good to go

For iTerm2, you can set the option key as meta by going to iTerm > Preferences > Profile > (Active Profile) > Keys and you can see at the bottom of the pane there are radio choices for the options keys. Use +Esc to properly bind as the Alt-key.

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

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

For a bigger table, see Kakoune explain keys

Key Description ALT + key CTRL + key g key (goto)
a insert after selected text select whole object last buffer
A insert at line end
b select to previous word start select to previous WORD start scroll one page up window bottom
B extend to previous word start extend to previous WORD start
c change selected text change selected text without yanking window center
C copy selection on next lines copy selection on previous lines
d erase selected text erase selected text without yanking
e select to next word end select to next WORD end buffer end
E extend to next word end extend to next WORD end
f select to next character included select to previous character included scroll one page down file
F extend to next character included extend to previous character included
g go to location
G extend to location
h move left select to line begin line begin
H extend left extend to line begin
i insert before selected text select inner object jump forward in jump list line begin (non blank)
I insert at line begin
j move down join lines buffer bottom
J extend down join lines and select spaces
k move up keep selections matching given regex buffer top
K extend up keep selections not matching given regex
l move right select to line end force screen redraw line end
L extend right extend to line end
m select to next matching character select to previous matching character
M extend to next matching character extend to previous matching character
n select next current search pattern match select previous current search pattern match
N extend with next current search pattern match extend with previous current search pattern match
o insert on new line below add a new empty line below jump backward in jump list
O insert on new line above add a new empty line above
p paste after selected text paste every yanked selection after selected text
P paste before selected text paste every yanked selection before selected text
q replay recorded macro
Q start or end macro recording
r replace with character
R replace selected text with paired yanked text replace selected text with all yanked texts
s select regex matches in selected text split selected text on line ends push current selections in jump list
S split selected text on regex matches select first and last characters of each selections
t select to next character select to previous character window top
T extend to next character extend to previous character
u undo move backward in history
U redo move forward in history
v manipulate view
V lock view mode
w select to next word start select to next WORD start
W extend to next word start extend to next WORD start
x select line extend selections to whole lines
X extend line crop selections to whole lines
y yank selected text
z restore selections combine selections from register
Z save selections combine selections to register
external shell commands
! insert command output append command output
$ pipe each selection through shell command and keep the ones whose command succeed
| pipe each selection through filter and replace with output pipe each selection through command and ignore output
align / indent
& align cursors copy indentation
@ convert tabs to spaces convert spaces to tabs
< deindent deindent, not including incomplete indent
> indent indent, including empty lines
% select whole buffer
( rotate main selection backward rotate selections content backward
) rotate main selection forward rotate selections content forward
; reduce selections to their cursor swap cursors and anchors
_ trim selections merge contiguous selections together
* set search pattern to main selection content set search pattern to main selection content, do not detect words
/ select next given regex match select previous given regex match
? extend with next given regex match extend with previous given regex match
[ select to object start select to inner object start
] select to object end select to inner object end
{ extend to object start extend to inner object start
} extend to object end extend to inner object end
text case
` convert to lower case swap case
~ convert to upper case
, user mappings
. repeat last insert command repeat last object or t/f selection command last buffer change
\ disable hooks
: enter command prompt ensure cursor is after anchor
" choose register
Up move up
Down move down
Left move left
Right move right
Home select to line begin
End select to line end
PageDown scroll one page down
PageUp scroll one page up
Space remove all selections except main remove main selection
Backspace remove count
Escape end macro recording


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 %{ %sh{
  if [ $kak_count = 0 ]; then
    echo "$1"
    echo "exec ${kak_count}0"
You can’t perform that action at this time.