Two modes:
command mode: cursor moving, ...
insert mode: insert characters .. (ESC to command mode)
Command Mode:
cursor moving: hjkl or arrow keys
scrolling: ^F, ^B, ^D, ^U
jumping to: num G, :num (keying the number, then G, no space)
deleting: dd, delete current line
num dd, delete num lines
dw, delete a word
num dw, delete num words
x, delete current char
X, delete previous char
paste: p, paste after
P, paste before
copy: yy, copy current line
num yy, copy current num lines
search: /, forward search
?, backward search
n, repeat previous search
N, repeat previous search but in opposite direction
search and replace:
:num1, num2 s/pat/replaced/[gc]
for example:
:1,$ s/buffer/BUF/ from first line to last line
:.,$ s/money/Money/gc from current line to last line
Insert Mode:
insert: i, insert before
a, append after
I, insert at the beginning of the line
A, append to the end of the line
new line: o, a new line after
O, a new line before
File:
write back: :w save
:w fn save to fn
quit: :q quit
:wq save and quit
:wq fn save to fn and quit
ZZ save and quit
read a file :r fname the content of fname will be inserted below current line