VI learning note 1

two modes:

command mode and insert mode


:q quit

:q! quit without save

:w save(write) but not quit

:wq save and quit

:e! return to the last saved version

:!command run command in vi

:sh create a shell( CTRL-D return to vi )

also ok: CTRL-Z to suspend vi, run commands, type fg to return to vi




ZZ quit and save

i begin insert mode

ESC return to command mode

h left, one space

l right, one space

j down, one line

k up, one line


4l equal to type l command for 4 times


0(zero) move to beginning of line

$ move to end of line


w move one word forward at a time

b move one word backward at a time


G move to the last line

5G move to the 5th line

:set nu show line numbers


a append text


cw to change of a word

r to change of a character (return to command mode automatically)

c2b change back to 2 words

c$ change to the end of line

c0 change to the beginning of line

cc change entire line(the same to C)