VIM Keybindings

Cheat sheet for vim, a terminal based text editor.

Moving

keys / commandfunction
hright
jup
kdown
lleft
wnext word
bprevious word
Wnext word space separated
Bprevious word space separated
eend of word
0start of line
$end of line
^first character of line
Hfirst line on screen
Mline in middle of screen
Llast line on screen
:n <Number>go to line number
Ctrl + dmove down half page
Ctrl + umove up half page
}move down until next blank line
{move up until next blank line
gggo to top of page
Ggot to bottom of page

Files

keys / commandfunction
:e <Name>open file
:wwrite changes
:qquit, wont work if not saved
:q!quit without saving
:wqwrite and quit
:xsave and exit if changes have been made, just quits when nothing changed
:wqasave all and quit
ZZwrite and quit
ZQquit without saving

Editing Text

keys / commandfunction
~change case of character
>indent right
<indent left
ccut out highlighted text
yyank highlighted text
ddelete highlighted text
yyyank current line
dddelete and yank current line
pinsert text after cursor
Pinsert text before cursor
xdelete character under cursor
Xdelete character before cursor

Insert and Overwrite Text

keys / commandfunction
ienter insert mode, insert before cursor
Iinsert at start of line
aappend after cursor
Aappend at end of line
onew line below
Onew line above
Cchange rest of line
roverwrite single character
Rinsert mode but for replacing

Search and replace

keys / commandfunction
/<pattern>look for pattern forward
?<pattern>look for pattern backwards
nnext match
Nprevious match
:%s/<old>/<new>/gnreplace old with new
:%s/<old>/<new>/gcreplace old with new, needs confirmation
f <char>move forward to next char
F <char>move back to char
t <char>move forward in front of char
T <char>move back before char

Undo and Redo

keys / commandfunction
uundo
Uundo only current line
Ctrl-rredo

Tabs

keys / commandfunction
:tabmake new tab
gtgo to next tab
gTprevious tab
:vspvertically split
Ctrl + wssplit horizontal
Ctrl + wvsplit vertical
Ctrl + wwswitch window
Ctrl + wwquit window

This list might be expanded

Last modified 2021.01.01