| Contents | Xiaorang Li's Homepage |
vim file_name
vim
:wqor
ZZ
:wq newname
:q
If :q doesn't work, it's probably because you didn't save the change. If you want to save, use :wq. If you don't want to save the changes, type
:q!
The two basic modes of vim are.
After you start vim, you're in command mode.
i
Remember: these commands work only in command mode. At first you may feel a bit uncomfortable. After you get familiar using these commands you will stick to them and forget the arrow keys.
yyto make a copy of the line, or
ddto cut it and make a copy
pto put the buffer after current line, or
Pto put the buffer before current line
8yyto copy 8 lines.
/applefollowed by ENTER to find an occurrence of apple. When you type the slash, it and the following characters will be shown on the bottom of the screen. After you press ENTER, the cursor will go to the first occurrence of apple if found, and the target will be highlighted.
nto find other apples
:s/old/new/
:s/old/new/g
:n1,n2s/old/new/
:n1,n2s/old/new/g
:1,$s/old/new/gc
:%s/old/new/gc
| Contents | Xiaorang Li's homepage |