How to use vi(m)
Vim has three modes. Insert mode, command mode and visual mode.
VIM is case sensitive!!
Quit
To quit, you should be command mode. Just type esc! and type this.
:q
If you want to save the text, type this.
:w
If you want to quit, but doesn't save,
:q!
And, you want to save and quit,
:wq
Move
When vim is in command mode, you can move the cursor via h,j,k and l commands
- h - left
- j - down
- k - up
- l - right
You can also move through the words
- w - jump word forward at first
- e - jump word at last
- b - jump backword
You can go to some lines
- gg - go to ground(end) line.
- G - go to start line.
- #G - go to # line. # is number.
Insert
You can modify the text.
- i - changed to insert mode. you can insert text.
- a - changed to insert mode, after current cursor.
- r - change a character.
- o - add a line after cursor.
- O - add a line before cursor.
You can change mode by esc key.
If you want to undo, type u.