1. Read and write status switch
A: Write
ESC: Read
2. Save and exit
Save: W
Exit: Q
Save exit: Wq
Add an exclamation mark to force save or exit: w!, q!
3. Jump to the end of the line
0: Jump to the beginning of the line
shift+$: Jump to end of line
4. Copy, cut/delete rows, paste
Single-line replication: yy
MultiRow copy: Nyy
Single-line cut/delete: DD
Multi-line Cut/delete: NDD
Paste: P
5. Find
/pattern: Find pattern Match string down
? pattern: Find pattern Match string up
N: Continue searching in the same direction
N: Continue searching in the opposite direction
Pattern can contain special characters, including spaces,/, ^, $, *,.
6. Replace
: s/vivian/sky/#替换当前行第一个 Vivian for Sky
: s/vivian/sky/g #替换当前行所有 Vivian for Sky
: N, $s/vivian/sky/#替换第 the first Vivian of each row in line n start to the last row is sky
: N, $s/vivian/sky/g #替换第 n lines start to the last row all Vivian for each row are sky
(n is a number, if N is., representing the beginning of the current line to the last row)
:%s/vivian/sky/# (equivalent to: g/vivian/s//sky/) replaces the first Vivian of each line as Sky
:%s/vivian/sky/g # (equivalent to: g/vivian/s//sky/g) replaces all Vivian in each row as Sky
7, display line number
: Set Nu
8. Comment Lines
Comment Line: #
9. Jump to a line
: LineNum
10, jump to the end of the file
Jump to end of file: Shift+g
Jump to the beginning of the file: GG
Finally attached an old picture, personally feel very useful
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/85/5C/wKioL1ehhDuShYF6AATsZ3_vMHU740.png "title=" vi.png "alt=" Wkiol1ehhdushyf6aatsz3_vmhu740.png "/>
This article is from the "袁喆玺 blog" blog, make sure to keep this source http://yuanzhexi.blog.51cto.com/7786823/1833924
Use of the VI command under Linux