VI Edit Command
1.VI [file_name] //Edit files
2.h, J, K, L //Move cursor
3.ctrl+f //Page Down
4.ctrl+b //PAGE UP
5.ctrl+d //Upside down half page
6.ctrl+u //Turn up half a page
7.n+ //n represents a number, jumps to the n characters of the current line, and the string index starts at 0.
8.0/home Jumps the first character of the current line
9.$/end //Jump to the last character of the current line
10.H //The first character of the first line of the current screen
11.M //The first character of the middle row of the current screen
12.L //The last line of the current screen, the first character
13.G //Move the last line of the file
.NG //move n rows
15.gg //Move First line
16.n+/n[enter] //Move Down n rows
-----------------Find/Replace-------------------------------------------
17./[word] Look down word string, Word mutable string
18.? [Word] //Search up word string, Word variable string
19.N //Repeat search down to find commands performed
20.N Repeat search up to find commands performed
21.:n1,n2s/[char]/[char]/g //In N1,N2 line find word replace word2, and finally add C, prompt to replace
21.:1, $s/[char]/[char]/g//Replace in first line to last line
-----------------Delete-------------------------------------------
22.x //Remove one character backwards
23.X //delete one character forward
24[n]x/[n]x //forward/backward removal of n characters
25.dd //delete current cursor positive line
26.[N]DD //delete n rows down
27.D1G //Delete the current cursor to the first line
28.dG //delete current cursor to last line
29.d$ //Delete the last character of the cursor line
30.d0 //Delete the first character of the cursor line
-----------------Copy/paste-------------------------------------------
31.yy //Copy cursor line
32.[n]yy //copy cursor down n rows
33.Y1G //Copy first row of data
34.yG //Copy last line
35.y0 Copy all data from the cursor to the first row
36.y$ //Copy all data from the cursor to the last row
37.P //Paste on the previous line of the cursor
38.P //Paste on the next line of the cursor
39.J //merge cursor with Next line
40.u //Restore previous operation
41.ctrl+r//Repeat Last action
42.. //Repeat Last action
43.:setnu //Set line number
44.:set Nonu //Cancel line number
45.:w //Save file but do not exit VI
46.:w! Force save, do not exit VI
47.:wq //Save file and Exit VI
48.:wq! //Force save file and Exit VI
49.Q: //Do not save files, exit VI
50.:q! //Do not save file, Force exit VI
51.:e! //Discard all changes and edit from the last save file
Linux VI edit Common key instructions