foyer

havre

vim

vim notes

0to line beginning
$to line end
^to first non-space character on the line
g_to last non-space character on the line
ggto first line
Gto last line
g;to last edit
12Gto line 12
Ctrl + escroll one line down
Ctrl + yscroll one line up
Hto viewport head
Mto viewport middle
Lto viewport bottom

word nav

wto next word’s beginning
eto next word’s end
bto previous word’s beginning
geto previous word’s end

substitution

command mode:

:s/meat/veggies/gsub "meat" with "veggies" in a line
:%s/meat/veggies/gsub in all lines
:16,18s/meat/veggies/gsub in lines 16–18
/mieusearch forward for "mieu"
?mieusearch backward for "mieu"
/\cmieusearch for "mieu" and ignore cases
/\<mieu\>search for "mieu" exactly

misc

commands

:wsave, write changes to file
:updatesave only if there are changes
:xexit
:qquit

modes

normal

xcut a character
ddcut a line
dawcut current word with spaces
yycopy line
y$copy to line’s end
yiwcopy current word sans spaces
ppaste after
Ppaste before
gppaste after and move cursor after pasted text
uundo
Ctrl + rredo
Ctrl + aincrease number (on cursor)
Ctrl + xdecrease number (on cursor)

insert

iinsert at cursor
ainsert after cursor (append)
Iinsert at current line’s start
Ainsert at current line’s end
oinsert new line below current line
Oinsert new line above current line
sdelete character under cursor
Sdelete all text on line
cwdelete to current word’s end
Cdelete from cursor to line’s end

visual

vhighlight
Vhighlight line
Ctrl + vhighlight block
ddelete (cut)
yyank (copy)
pput (paste)

resources