-
Notifications
You must be signed in to change notification settings - Fork 751
Normal mode commands
Elfogadodhe edited this page Mar 28, 2024
·
73 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.
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
| 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 | scroll one half page down | ||
| D | |||||
| 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 | undo last selection change | 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 | (ambiguous) | buffer bottom | |
| J | extend down | join lines and select spaces | |||
| k | move up | keep selections matching given regex | redo last selection change | 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 | (ambiguous) | ||
| 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 | scroll one half page up | ||
| 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 | expand selections to contain full lines (including end-of-lines) | trim selections to only contain full lines (not including last end-of-line) | |||
| X | |||||
| y | yank (copy) selected text | ||||
| Y | |||||
| 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 | |||
| selections | |||||
| % | select whole buffer | ||||
| ( | rotate main selection backward | rotate selections content backward | |||
| ) | rotate main selection forward | rotate selections content forward | |||
| ; semicolon |
reduce selections to their cursor | swap cursors and anchors | |||
| _ | trim selections | merge contiguous selections together | |||
| search | |||||
| * | 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 | |||
| text-objects | |||||
| [ | 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 | ||||
| , | clear selections to only keep the main one | clear the main selection | |||
| . | 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 | ||||
| ' | |||||
| # | |||||
| ^ | |||||
| - | |||||
| = | |||||
| + | duplicate each selection (generating overlapping selections) | merge overlapping selections | |||
| 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 | enter default user mode to access custom commands | ||||
| Backspace | remove count | ||||
| Escape | |||||
| Return | |||||
| Tab | often interpreted as ctrl+i | ||||
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
}}
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV
