Linux operation and Maintenance Phase II (ii) VI Editor
VI Editor (full-screen plain text editor)
1. Command mode, insert mode, last line mode
2. a insert in the word specifier the cursor
a at the end of the line where the cursor is inserted
I insert in the word match either the cursor
i insert at the beginning of the line where the cursor
o insert a new line under the cursor
o insert a new line on the cursor
: w Save
: Q do not save exit
: Wq Save Exit
: q! Force Exit
: w file name Save As
3, the HJKL corresponds to the lower left upper right
GG File Header
end of g file
^ beginning
$ End of Line
: N move to the first few lines
x Delete a single character
NX Delete N of characters
DD Delete a single line (or cut)
: n1,n2d Delete a specified range of rows
NDD Delete N Line
P after pasting to the cursor
P paste before the cursor
yy Nyy Copy
u Revoke
Ctrl+r Anti-Revocation
R The character at which the cursor is replaced
R start replacing at the cursor, <esc> End
: Set Nu Show Line Numbers
: Set Nonu do not display line numbers
: Syntax On|off Color Switch
/ content Find a string (n - down,n to look up )
: 1,10s/old/new/g Replace 1 to 10 rows of Old to be New
:%s/old/new/g replace the entire file. Old to be New
: 1,5s/^/#/g Note 1 to 5 lines (at the beginning of the # )
: 1,5s/^#//g Uncomment 1 to 5 lines
: 1,5s/^/\/\//g file Header Join //
Note:/g (all within range)
From Brother Lian Training
Linux Operations Phase II (II) VI editor