Here patients to / etc / passwd top ten acts
First, vi is the Linux terminal or console conventional editor, the basic mode of operation is:
vi / path / filename
after entering the press "a", "i", "o" keys can edit the file
Method exits vi editing mode:
Press the "esc" key, enter ": q!" To force quit (Note that the "colon" is a must), "q!" Was forced to withdraw (without saving the current editor) input ":! wq" to save and exit (same here, "colon" is a must).
Or: Insert key is pressed, the window can see the left-bottom "Insert" word representing the current editing state to be inserted, this time from the contents of the keyboard input is inserted at the cursor position; Insert key is pressed again, the lower left corner of the " replace "word representing the current state of editing Alternatively, this time from the contents of the keyboard input replace the contents of the cursor position.
Shortcut keys:
First press "esc" to enter the command mode
-
"Yy" Copy the current cursor line, "3yy" Copy the current cursor row and two rows located below the row;
-
"P" to paste the copied content to the row below the cursor;
-
"Dd" to delete the cursor line content, "3dd" delete the current cursor line and the following two lines;
-
"U" to return to previous operation ( "withdraw")
-
"G" cursor to the last row;
-
"Gg" cursor to the first line;
-
"DG" Delete cursor line to the end of the file;
Find the shortcut file contents
: Press the "esc" key, enter ": \ field to find what you want". The cursor will move to the first file in the contents of the location you entered, then press the "N" key, to be Find the same field contents, pressing the "n" key will look up the same. (Note: Here "colon" and "" are a must!).
Replace the contents of the shortcut file
Syntax: s/xx/xx
Replace cursor line content you want to replace (the first "xx" input field contents you want to replace the second "xx" Enter what you want to replace the contents of the field).
Example:
we must enter ": s / root / mark"
So if you want to "root" the entire line are replaced by "mark", then: You can enter ": s / root / mark / g" ( where " g "can be understood as" global "global (whole line))
expansion: ①," s "can be replaced with"% s "representative of full replacement ("% s / root / mark " the full text of the" root "replace" mark ");
②," may be replaced by S "3,5s" ( "3,5s / root / mark" the "root" of the third row and the fifth row replaced by "Mark");
③, "also S can be replaced ". 3, $
S" ( ". 3, $
S / the root / Mark" the third row to the last row of the "root" replace "mark").
Extended command mode
Enter ": set nu" display text line numbers.
Enter ": set list" to display the full text of blank lines.
Summary: The above is the basic operation vi mode, do not know if there is the little sister of the micro-channel can be added: 1,430,016,196.